Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1224.Advanced search and replace -- How to replace each line with line have same start word from another file?

User: Aaron -- 2014-08-02          << 1223  1225 >>
Hits: 941
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
I would like to replace each line of a source file from lines in a target file
based on the first word. If the target file does not contain a line starting with
a word found in source file then source file line remains.
Input Sample:
Source file:

The man ran up the hill.
He was out of breath at the top.
He was also very thirsty.
"I need a drink of water" he said.
Then he turned around and ran back 
down again.
Unfortunately, he tripped and broke 
his leg.


Target file:

So you think you can win the 
competition?
He looked like he was a strong 
swimmer.
The first prize was a trip to the 
world finals.
He took a deep breath.
"I can do it."
Then he smiled.
"Good for you."
Output Sample:
Output file:

The first prize was a trip to the 
world finals.
He took a deep breath.
He looked like he was a strong 
swimmer.
"I can do it."
Then he smiled.
Unfortunately, he tripped and broke 
his leg. 
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
Assume the target file is d:\test\target.txt
1. ctrl-o open source file
2. ctrl-h open 'replace' window
* set 'replace unit' to 'Line'
* 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 use double backslah for folder delimiter like: d:\\test\\target.txt

Screenshot 1:  Replace_Window


Screenshot 2:  Replace_Advanced_Window


Similar Examples:
How to replace the quoted text with lines from another file? (67%)
How to replace a string in one text file with random words from another file? (67%)
How to replace each xxx with the first word in the same line in text file? (64%)
How to duplicate each line 5 times in a text file? (62%)
How to remove all lines that can be found in another file? (61%)
How to replace strings in one file with words from another file sequentially? (60%)
How to replace everything outside brackets with lines from another file? (60%)
How to replace the content of XML with a list of words from text file? (60%)

Check Demo of Advanced search and replace
Keywords:
line starting with  starting with  starting  based on  found  double  another file  delimiter  same  first word  double words  replace starting with  replace starting  split file delimiter  double lines  lines contain words  split txt file each lines  tab delimiter