Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

391.Advanced search and replace -- How to search and replace text 'ReplaceMe' only in specified lines?

User: editor -- 2010-01-15          << 390  392 >>
Hits: 335
Type: Advanced search and replace   
Search all Advanced search and replace examples
Description:
I have a file that I need to search 'ReplaceMe' and replace with 'New', but the replace shall only happen in the lines that contain 'ReplaceThisLine'.
Input Sample:


... ReplaceThisLine ... ReplaceMe .... ReplaceMe ...
... ReplaceMe .... ReplaceMe ....
... ... ReplaceThisLine ... ... ReplaceMe ....
... ReplaceMe ....
Output Sample:
... ReplaceThisLine ... New .... New ...
... ReplaceMe .... ReplaceMe ....
... ... ReplaceThisLine ... ... New ....
... ReplaceMe ....
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' dialog:
* set 'Replace Unit' to 'Chars'
* set 'Replace Scope' to 'Line'
* set 'Search for pattern' to:

* set 'Replace with pattern' to:

* click 'Scope Filter' page, set 'Line Pattern' to:

3. Click 'Replace', done.
4. Ctrl-s save to file.
Download Script:  scripts/391.rst.zip

Similar Examples:
How to search and replace text for specified occurrences with reg exp? (68%)
How to search and replace words in specified column in csv file? (64%)
How to search and replace in multiple files base on user-defined mapping file? (59%)
How to replace word 'abc' to 'def' in specified lines like 1-10,18,20? (58%)
How to batch replace text that contains special characters like $,{,} ? (57%)
How to change text file format with user specified rules? (57%)
How to batch replace 'old' to 'new' in many pdf files? (57%)
How to search and replace multiple files with rules different in sequence number? (56%)

Check Demo of Advanced search and replace
Keywords:
scope filter  ppen  scope  replace scope  filter  chars  app  contain  new  lines  only search text  lines contain  replace but  search and replace open source  replace pattern in text file  replace text pattern  search pattern  text pattern