| User: editor -- 2010-01-11 << 388 390 >> |
| Hits: 397 |
| 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 reverse a text file by characters? (60%) How to keep all specified words in an article and remove rest words? (58%) How to sort the comma separated words by the length of words? (56%) How to save specified lines of text file into different files? (55%) How to generate a csv file from a template file and a list of words? (54%) |
Check Demo of Regular expression replace |
| Keywords: |
| free boundary whole words what whole syntax nth space regular expression expression space syntax whole words only words to replace preceded replace whole word replace space in text file replace space in text only search text replace space |