在 Sublime 的不同块中跨行匹配字符
Match characters across line in different blocks in Sublime
假设我有一个如下所示的文本文件:
Block 1 start
Line 1 in Block 1
Line 2 in Block 1
Block 1 end
Block 2 start
Line 1 in Block 2
Block 3 start
Line 1 in Block 3
Block 3 end
如何在 Sublime 中 select Block 1 和 Block 3(包括起始行和结束行)并跳过 Block 2 的两行?
(?s)Block (\d+) start.+Block end
(?s) - basically a multiline modifier. Allows the `.` to match newlines.
Block (\d+) start - Matches the start of a block
.+ - Capture everything inside the block
Block end - Finds the end of the block by using the number found at the beginning in the Block start section.(back referencing)
这应该适用于您想要跳过没有有效结束部分的块的情况。
如果数据格式不正确,那么您将 运行 遇到问题。例如,如果 Block 1 end
之类的东西恰好在块内。
假设我有一个如下所示的文本文件:
Block 1 start
Line 1 in Block 1
Line 2 in Block 1
Block 1 end
Block 2 start
Line 1 in Block 2
Block 3 start
Line 1 in Block 3
Block 3 end
如何在 Sublime 中 select Block 1 和 Block 3(包括起始行和结束行)并跳过 Block 2 的两行?
(?s)Block (\d+) start.+Block end
(?s) - basically a multiline modifier. Allows the `.` to match newlines.
Block (\d+) start - Matches the start of a block
.+ - Capture everything inside the block
Block end - Finds the end of the block by using the number found at the beginning in the Block start section.(back referencing)
这应该适用于您想要跳过没有有效结束部分的块的情况。
如果数据格式不正确,那么您将 运行 遇到问题。例如,如果 Block 1 end
之类的东西恰好在块内。