User: Dilip -- 2014-11-26 << 1264 1266 >> |
Hits: 3393 |
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 |