Thursday 8 January 2015

IntelliJ find and replace: How to remove all lines not containing a certain text

This is essentially just an exercise in Regex but it's a little tricky (at least I found it non-trivial).

Supposing you want to remove all lines not containing xxx this is how you would go about it.

In the find box type: 

^((?!xxx).)*\n

and just leave the replace box empty. 



5 comments: