Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

1265.Regular expression replace -- How to search and replace multiple file with multiple regex rules?

User: Dilip -- 2014-11-26          << 1264  1266 >>
Hits: 1335
Type: Regular expression replace   
Search all Regular expression replace examples
Description:
This is advanced dictionary usage. I have some list of two words which have
various spelling errors. The dictionary only replaces one word. So I want

m(\w+) benz=mercedes benz
(M)(\w+)(L) Schumacher=$1ichael Schumacher

Please notice i am also using $1 replacement in dictionary for Michael
Schumacher
Input Sample:
merc benz
merzedes benz
merces benz
Mikhail Schumacher
Miguel Schumacher
Output Sample:
mercedes benz
mercedes benz
mercedes benz
Michael Schumacher
Michael Schumacher
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
Suggest to use "Fast Replace" funcion in "Batch Runner" menu to do replacement with multi-rules.
0. prepare a file dictionary.txt with one rule in each line:
m(\w+) benz=mercedes benz
(M)(\w+)(L) Schumacher=$1ichael Schumacher
...
1. open "Tools->Batch Runner" menu
2. from Windows "File Browser", drag multiple files you want to change and drop to "Batch Runner" window.
3. click "Fast Replace" button
drag the dictionary.txt to the rule list in "Fast Replace" window(or click "Import" to import dictionary.txt)
The rules will be imported like:
search: replace:
search: replace:
...
4. check option of "reg exp" and "whole word", note: for older version without "whole word", you can add \b before and after each search pattern like: \bm(\w+) benz\b 
5. click "start", done.

Screenshot 1:  Fast_Replace_Window


Similar Examples:
How can I search and replace multiple strings in multiple files all at once? (72%)
How to replace text files using multiple pre-defined rules? (70%)
How to search/replace multiple text files base on rules from csv file? (69%)
How to search and replace strings in multiple utf-8 encoded text files? (68%)
How to search replace multiple files with distinct search replace definition for each? (66%)
How to search and replace multiple files with rules different in sequence number? (64%)
How to search and replace in multiple files base on user-defined mapping file? (63%)
How to replace multiple text in multiple files with variable strings? (63%)

Check Demo of Regular expression replace
Keywords:
regex  error  whole word  two words  before and after  whole  replacement  dictionary  diction  dic  regex be  regex replace add 1  add words before each line  regex replace  whole words only  use word dictionary file  search replace whole line  whole words