Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1290.Advanced search and replace -- How to mark out lines that do not match pre-defined condition?

User: colin -- 2015-03-25          << 1289  1291 >>
Hits: 1121
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
I have 2 text files
they both contain the same words: one word per line
but broken down into separated values (file1=sounds and file2=letter combinations)
So for each line in file 1 and 2 I want to check that there are equal number of
separated values .
ie if file1 line 1 has 5 separated values then file2 MUST have 5 values also
otherwise append "FIXME-" on file2
Input Sample:
file1.txt
garage,g,a,r,a,ge,,,,,,,,,,,,,,,,,,,,  [ e.g this has 5 separated values g a r a ge ]
garaged,g,a,r,a,ge,d,,,,,,,,,,,,,,,,,,,
garageman,g,a,r,a,ge,m,a,n,,,,,,,,,,,,,,,,,

file2.txt
garage,g,a,r,j,,,,,,,,,,,,,,,,,,,,,,,,,,,, [ e.g this has only 4 separated values g
a r ge  but should have 5 ]
garaged,g,u,r,o,zh,d,,,,,,,,,,,,,,,,,,,,,,,,,
garageman,g,u,r,o,zh,m,a,n,,,,,,,,,,,,,,,,,,,,,,,
Output Sample:
file2.txt
FIXME-garage,g,a,r,j,,,,,,,,,,,,,,,,,,,,,,,,,,,,
garaged,g,u,r,o,zh,d,,,,,,,,,,,,,,,,,,,,,,,,,
garageman,g,u,r,o,zh,m,a,n,,,,,,,,,,,,,,,,,,,,,,,
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
put file1.txt and file2.txt into d:\test\ folder
1. ctrl-o open file2.txt
2. ctrl-h open 'replace' dialogue
* set 'replace unit' to 'Line'
* set 'search for pattern' to:

* set 'replace with pattern' to:

* set 'if' to:

* click 'advanced' tab, set 'run following at the beginning of replace' to:

3. click 'replace', done.

Note: please change location of file1.txt in step 2, if your file is in other location.

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to merge consecutive lines that have the same first column? (55%)
How to filter out all web pages that does not contain specified words? (55%)
How to remove all the lines that do not contain any of words in a list? (53%)
How to remove lines where the last column does not match column 4? (52%)
How to add first line to the start of each line? (51%)
How to make following user defined format conversion? (51%)
How to randomly replace each word with a list of pre-defined words? (50%)
How to change the order of lines according to specified position? (50%)

Check Demo of Advanced search and replace
Keywords:
equal number  combinations  condition  combination  equal  mark  grep  var  define  one word per line  3 letter combinations  words equal  count number of each letter  count number of each letter in text  count same word  split lines into words  match condition  split text file into number of lines