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: 361
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 the last occurance of some text like 'abc' to 'def' in a text file? (61%)
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 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%)
How to replace the characters in fixed position in each line? (55%)
How to replace each xxx with the first word in the same line in text file? (54%)
How to replace all numbers 93 in every line that contains gas? (54%)

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