
例如:
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}
正規表示式