Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

386.Regular expression replace -- How to search and replace multiple terms with 1 common term in text file?

User: editor -- 2010-01-08          << 385  387 >>
Hits: 2256
Type: Regular expression replace   
Search all Regular expression replace examples
Description:
I have multiple terms that I want to search for and replace with 1 common term within a string of text without changing anything else.
Can your software help me.
e.g.
search for occurrences of ABIBLITY,ABIL,ABILATY,ABILILTY,ABILTITY,ABILITIY,ABILILITY,ABILIT,ABILITIE,ABILITIES,ABILITT,ABILITY,ABILITYTO,ABILIY,ABILLATY,ABILLITY,ABILTY,ABLITY,ABITLITY,ABLILTY,ALIBITY,AABILITY,ABAILITY,ABILIITY,CAN,ABLE,ENABLE,ENABLES,ENABLED,ENABLING
replace each found occurrence within the string with ABLE
Input Sample:
Yamaha financing section unclear as to availability of various rates for
particular models. Either unable to obtain preapproval online or just
couldn't find it. 
Output Sample:
Yamaha financing section unclear as to availABLE of various rates for
particular models. Either unABLE to obtain preapproval online or just
couldn't find it
Answer:
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps.
1. ctrl-o open your source text file
2. ctrl-h open 'Replace' window
* in search for pattern enter:

Note: each term is separated with "|", the words should be sorted by the length, e.g. ABILITITY should come before ABIL because longer string should have higher priority, please refer to:
http://www.mind-pioneer.com/services/387_Advanced_search_and_replace.html
for how to sort it in one step.

* check "Ignore Cases" option
* in 'Replace with Pattern' enter:

or

3. Click 'Replace' button, all occurances of pre-defined phrase will be replaced with ABLE.
Download Script:  scripts/386.rst.zip

Screenshot 1:  Replace_Window


Similar Examples:
How to search and replace strings in multiple utf-8 encoded text files? (72%)
How can I search and replace multiple strings in multiple files all at once? (66%)
How to search and replace words in specified column in csv file? (63%)
How to extract multiple lines in specified order from many text files? (61%)
How to extract multiple webpages and save all text into text files? (61%)
How to search and sum the numbers at specified position in a text file? (60%)
How to find and replace multiple line text? (60%)
How to search/replace multiple text files base on rules from csv file? (59%)

Check Demo of Regular expression replace
Keywords:
anything  terms  software  bit  within  occurance  common  phrase  grep  length  sort by occurrence  how to sort by occurrence  how to search for multiple terms  how to replace in text file with common expression  sort words by length in text file  text file sort by length  sort by length  how to sort by length in text file