Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

196.Advanced search and replace -- How to remove/delete all lines not containing 'abc'(only keep lines containing 'abc')?

User: editor -- 2008-06-21          << 195  197 >>
Hits: 2035
Type: Advanced search and replace   
Search all Advanced search and replace examples
How to remove all lines not containing 'abc'(only keep lines containing 'abc')?
Input Sample:
line1 xxxx 
line2 abc dddddd 
line3 ffffffffff 
line4 eeeeeeabcee
Output Sample:
line2 abc dddddd 
line4 eeeeeeabcee
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. ctrl-o open your text file  
2. ctrl-h open 'Replace' dialog  
* set 'Replace Unit' to 'Line'  
* set 'Search for pattern'  
* select option [v]Enhanced Regular Expression 
* set nothing in 'Replace with Pattern'  
3. click 'Replace', done!  
Note: here "!abc" here is a enhanced regular expression, "!" means not.
Download Script:  scripts/

Screenshot 1:  Replace_Window

Similar Examples:
How to remove/delete all lines containing '123456'? (63%)
How to extract all lines not containing 'ing' and 'and'? (60%)
How to remove/delete following text containing various time? (60%)
How to remove/delete all lines with even line number? (58%)
How to remove/delete all lines with even line number? (58%)
How to remove all lines that contain one or more words in a list? (57%)
How to remove all the lines that do not contain any of words in a list? (56%)
How to delete all lines that contain only a word and a blank? (55%)

Check Demo of Advanced search and replace
only keep lines containing  keep lines containing  enhanced regular expression  keep lines  lines containing  abc  delete all lines  not containing  keep  remove all lines  remove a lines with a regular  remove lines not containing text file  remove all lines containing  remove lines containing  replace lines not containing  remove text with regular expression  text search replace with nothing  replace abc