例如:
Important Line
Useless Line
Static Line
Important Line A
Useless Line A
Static Line
Important Line B
Useless Line B
Static Line
Important Line C
Useless Line C
Static Line
我们如何才能将它们变成:
Important Line
Important Line A
Important Line B
Important Line C
答案1
好吧,再深入挖掘一下。我找到了一个可行的解决方案。
(?m)(^[^\r\n]*\R+){1}Static Line[^\r\n]*\R+(^[^\r\n]*\R+){0}
正则表达式