
例えば:
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}
正規表現