User: Aaron -- 2014-08-02 << 1223 1225 >> |
Hits: 2988 |
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 |