Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

560.Text file parser -- How to remove all the lines that do not contain any of words in a list?

User: editor -- 2010-07-09          << 559  561 >>
Hits: 1815
Type: Text file parser   
Search all Text file parser examples
Description:
How to filter out all the lines that containing any of word in a list?
Input Sample:
word_list.txt
word1
word2
word3
...

input.txt
.....word1......
...............
....word2........
..word3...........
.................
Output Sample:
output.txt
.....word1......
....word2........
..word3...........
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. ctrl-o open word_list.txt
2. ctrl-h open 'replace' window
* in 'search for pattern', enter:

* in 'replace with pattern', enter:

3. click 'Replace', you will get words separated by "|", like: word1|word2|word3..., copy the string to clipboard

4. ctrl-o open input.txt
5. ctrl-h open replace window
* set 'replace unit' to 'Line'
* in 'search for pattern' paste the string get in step 3:

Note: can not be "word1|word2|word3|", need remove trailing "|"
* in 'replace with pattern' enter 
* uncheck option of "Print Unmatched Unit"
6. click "Replace", done!
7. ctrl-s save to output.txt
Download Script:  scripts/560.rst.zip

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Window


Similar Examples:
How to remove all lines that contain one or more words in a list? (83%)
How to extract all lines that contain words in a list? (77%)
How to delete all lines that contain only a word and a blank? (75%)
How to remove all lines that contains more than one word? (75%)
How to remove all lines that contain ABC but not contain DEF in text file? (69%)
How to extract all lines that contain words A and B and C? (69%)
How to extract all lines do not contain a list of keywords? (68%)
How to remove lines that contain some words base on percentages? (68%)

Check Demo of Text file parser
Keywords:
remove trailing  trailing  clipboard  remove all the lines  separate  copy  containing  unmatched  string  unmatch  search file for lines containing all words  copy string  lines not containing word  copy paste  remove string  remove a string  replace words by list  copy lines