Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

370.Regular expression replace -- How to replace the last occurance of 'old' in every line with 'new'?

User: editor -- 2009-12-19
Hits: 132
Type: Regular expression replace   
Search all Regular expression replace examples
Description:
There is a file containing many lines of text, and there are more than one occurance of 'old' in each line? How to only replace the last occurance of 'old' in each line with 'new'?
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 scope' to 'Line'
* in search for pattern, fill:

in replace with pattern, fill:

3. click 'Replace', ok.
4. ctrl-s save the file.
Download Script:  scripts/370.rst.zip

Similar Examples:
How to replace the last occurance of some text like 'abc' to 'def' in a text file? (61%)
How to replace the second character of every line to 4 in a text file? (60%)
How to replace the second character of every line to 4 in multiple files? (58%)
How to replace the characters in fixed position in each line? (55%)
How to replace word 'abc' to 'def' in specified lines like 1-10,18,20? (53%)
How to replace specific spaces into comma in each line of text file? (52%)
How to rename files to the last 10 chars of 3rd line of file content? (52%)
How to remove the first 10 characters of each line in text file? (52%)

Check Demo of Regular expression replace