regextextmateoniguruma

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


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 not containing the word "pad", and get this result, using Regular Expression?

apple ipad
hp touch pad

Solution

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