Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

443.Advanced search and replace -- How to insert a line after specific lines in a text file?

User: editor -- 2010-03-10
Hits: 109
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
How to insert a line after specific lines in a text file?

I have a text file containing some lines, I need to insert a line target=xxx after each line of source=xxx, how to do it automatically?
Input Sample:
replace=1
source=200
test=8000
....

source=260
test=999
Output Sample:
replace=1
source=200
target=200
test=8000
....

source=260
target=260
test=999
Answer:
Hint: You need to Download and install "Replace Pioneer" to finish following steps.
1. ctrl-o open source text file
2. ctrl-h open replace window
* set 'replace unit' to line
* in search for pattern, enter:

* in replace with pattern, enter:

3. click 'replace', done!

Note: this example require Replace Pioneer version 2.52 and above. You need to change steps if use 2.51 or earlier.
Download Script:  scripts/443.rst.zip

Similar Examples:
How to batch extract specified lines from a text file? (70%)
How to add a blank line after every 8 lines in text file? (70%)
How to sort and delete duplicate lines of a text file? (68%)
How to delete duplicate lines of a text file? (68%)
How to shuffle all the lines in a text file? (67%)
How to count the occurrance of specific pattern in each line of text file? (65%)
How to remove partially duplicated lines in a text file? (63%)
How to reverse the order of all the lines in a text file? (63%)

Check Demo of Advanced search and replace