0

我希望逐行捕获信息,但前提是满足某些标准。所以在下面的文件 A 中,我可以轻松地查找 123,然后在下一行查找 456。

但是,在不释放文件 A 上的匹配项的情况下,我无法继续在文件 B 中捕获 789。我不确定如何告诉正则表达式“在新行中查找它,如果它在那里,则捕获该行。如果它不存在,就留在当前行。”

如何实现?

档案一:

123

456

文件 B:

123

456

789

4

1 回答 1

0

I am not sure how to tell regex "look for this in a new line, if it's there, capture the line. if it's not there, just stay on the current line.

You could just match the new line as part of an expression repeated multiple times, e.g:

\d{3}(\n\d{3})*

Not sure of the specifics of exactly what you want to match but this is the best I could come up with without further info...

于 2013-09-07T12:30:46.900 回答