Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

448.Advanced search and replace -- How to replace every 3 instances found in a text file?

User: editor -- 2010-03-15
Hits: 103
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
How to replace every 3 instances found in a text file?

I have a text file with many occurrance of 'search', how to replace the 1,4,7,10 instances of 'search' to 'FIND'?
Input Sample:
search and replace
batch search
advanced search
advanced search and replace
replace and search
search binary files
batch search and replace
Output Sample:
FIND and replace
batch search
advanced search
advanced FIND and replace
replace and search
search binary files
batch FIND and replace
Answer:
Hint: You need to Download and install "Replace Pioneer" to finish following steps.
Replace Pioneer support replace specified occurrance of matched string by "unit number filter".
1. ctrl-o open source text file
2. ctrl-h open 'Replace' dialog
* in 'search for pattern', enter:

* in 'replace with pattern', enter:

* set 'unit number filter' to:

Note: 1<3>N means start from 1, increased with step of 3, until reach the instance N, when N is omitted, will search until reach last instance.
3. click 'Replace', done!
4. ctrl-s save to file
Download Script:  scripts/448.rst.zip

Similar Examples:
How to replace the second character of every line to 4 in a text file? (65%)
How to duplicate every letter of a-z and A-Z in a text file? (62%)
How to join every n lines into 1 line in a text file? (62%)
How to duplicate each line 5 times in a text file? (61%)
How to replace specific spaces into comma in each line of text file? (61%)
How to shuffle all the lines in a text file? (61%)
How to add a blank line after every 8 lines in text file? (61%)
How to reverse the order of all the lines in a text file? (60%)

Check Demo of Advanced search and replace