Replace Pioneer Home   All Examples   Free Download

 New request --free  RSS: Replace Pioneer Examples

389.Regular expression replace -- How to replace words in a text file only if they are whole words?

User: editor -- 2010-01-11          << 388  390 >>
Hits: 1894
Type: Regular expression replace   
Search all Regular expression replace examples
Description:
How to replace words in a text file only if they are whole words?
If I want to replace the search terms only if they are free
standing words, in other words, preceded and followed by a space, can
this be done? What is the syntax for this?
i.e. ' abil '|' ability ' replaced with ABLE
Input Sample:
availability
ability
abil
liability
Output Sample:
availability
ABLE
ABLE
liability
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
* in 'search for pattern', enter:

or

* in 'Replace with pattern', enter new word like:

3. click 'Replace', done!

Note: in Regular Expression, \b means word boundary.
Download Script:  scripts/389.rst.zip

Screenshot 1:  Replace_Window


Similar Examples:
How to replace the same words in text files with different strings? (67%)
How to replace all the numbers in a text file to the square value? (64%)
How to replace all the password field in text file with random chars? (61%)
How to keep the key words and delete all the other words? (60%)
How to reverse a text file by characters? (60%)
How to replace a list of words with one single word? (58%)
How to replace string in the Nth file with the Nth strings from a list? (58%)
How to keep all specified words in an article and remove rest words? (58%)

Check Demo of Regular expression replace
Keywords:
free  terms  boundary  whole words  whole word  whole  what  syntax  tax  nth  whole words only  space syntax  words to replace preceded  replace whole word  only search text  replace space in text file  replace space in text  replace word with other file