How to use a regular expression to remove lines without a word?

Victor Lam picture Victor Lam · Aug 11, 2011 · Viewed 21.4k times · Source

I am using textmate to edit a file. I would like to remove all the lines not containing a word. Here is an example.

apple ipad
hp touch pad
samsung galaxy tab
motorola xoom

How can i remove all the line with the word pad, and get this result, using Regular Expression??

apple ipad
hp touch pad

Thanks all.

Answer

kizu picture kizu · Aug 11, 2011

Replace ^(?!.*pad.*).+$ with empty string