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          << 369  371 >>
Hits: 2035
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" on windows platform 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

Screenshot 1:  Replace_Window


Similar Examples:
How to replace an random occurrence of an word with an random line? (67%)
How to replace the last occurance of some text like 'abc' to 'def' in a text file? (61%)
How to replace specified occurrance of some string to a list of words? (60%)
How to replace the first 3 spaces into comma in each line of text? (60%)
How to replace the second character of every line to 4 in a text file? (60%)
How to count and sort the occurrance of different lines? (59%)
How to replace the second character of every line to 4 in multiple files? (58%)
How to replace the 2nd and 3rd occurrences of some words in multiple files? (57%)

Check Demo of Regular expression replace
Keywords:
occurance  more than  every line  containing  the last  last  replace scope  scope  every  regular expression  last lines  lines containing  last line  line last  lines to new file  more replace  only search text  each line new file