簡體   English   中英

正則表達式與多行字符串

[英]Regex with multiline string

我正在嘗試使正則表達式從項目路徑差異文件獲取每個文件的差異。 這里是:

--- Training/main/1/a   (revision 18 06 2013 06:48)
+++ Training/main/1/a   (revision 18 06 2013 06:48)
@@ -1,1 +0,0 @@
-isdfsdfsdsadasdasd
\ No newline at end of file
--- Training/main/1/abc (revision After)
+++ Training/main/1/abc (revision After)
@@ -0,0 +1,1 @@
+isdfsdfsdsadasdasd
\ No newline at end of file
--- Training/main/1/test.txt    (revision 18 06 2013 06:48)
+++ Training/main/1/test.txt    (revision After)
@@ -1,1 +1,3 @@
-sfaa
\ No newline at end of file
+sfaaasdasssssdsadasdas
+
+test with moving files on depot
\ No newline at end of file

如何創建正則表達式模式以匹配每個文件的差異? 例如匹配:

差異1:

--- Training/main/1/a   (revision 18 06 2013 06:48)
+++ Training/main/1/a   (revision 18 06 2013 06:48)
@@ -1,1 +0,0 @@
-isdfsdfsdsadasdasd
\ No newline at end of file

差異2:

--- Training/main/1/abc (revision After)
+++ Training/main/1/abc (revision After)
@@ -0,0 +1,1 @@
+isdfsdfsdsadasdasd
\ No newline at end of file

如果可能的話,您可以分別生成差異嗎? 如果您有權訪問存儲庫,則這應該是最簡單的解決方案。

否則,您將無法通過正則表達式進行操作-任何行都可以以---+++開頭。 拆分更改的正確解決方案是實際解析diff格式,並跳過每個文件塊的指示數量的+-行和可能的其他指示符。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM