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: 370
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 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 remove all lines that are not ended with word "ok" or "done"? (68%)
How to remove all lines that have duplicate contents in CSV files? (67%)
How to filter out all web pages that does not contain specified words? (65%)
How to find out all files that contain all words of A, B and C? (65%)

Check Demo of Text file parser
Keywords:
copy  containing  string  unmatched  para  unmatch  input  not contain  filter  print  copy string  remove string  remove a string  copy paste  lines not containing word  replace words by list  copy lines  lines contain words