| User: editor -- 2010-01-11 |
| Hits: 124 |
| 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" 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 |
Similar Examples: |
| 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 reverse a text file by characters? (60%) How to sort the comma separated words by the length of words? (56%) How to replace a string in one text file with random words from another file? (54%) How to process text files, only keep the first word of each line? (54%) How to replace adjacent multiple spaces in a text files into one tab? (53%) How to batch replace word "old" in many files with different words "new1","new2",...? (53%) |
Check Demo of Regular expression replace |