User: editor -- 2012-01-25 << 905 907 >> |
Hits: 3616 |
Type: Regular expression replace |
Search all Regular expression replace examples |
Description: |
How to search and replace text for specified number of occurrences(times) using regular expression? For example, I want to search the first 3 numbers(with regular expression \d+), and multiply them by 2. |
Input Sample: |
the first number is 10, the second number is 20, the third is 30, the fourth is 40 |
Output Sample: |
the first number is 20, the second number is 40, the third is 60, the fourth is 40 |
Answer: |
Hint: You need to Download and install "Replace Pioneer" on windows platform to finish following steps. |
With Replace Pioneer, you can use 'unit number filter' to control how many occurrences you want to search and replace a string, even if you are using a regular expression. 1. ctrl-o open text file 2. ctrl-h open 'replace' dialogue * set 'search for pattern' to the text you want to search: * set 'unit number filter' to the occurrences you want to search(5..10 means 5,6,7,8,9,10): * set 'replace with pattern' to the text you want to replace(you can use function here!): 3. click 'replace', done. 4. ctrl-s save to file. |
Screenshot 1: Replace_Window |
Similar Examples: |
How to search and replace words in specified column in csv file? (69%) How to make search and replace only in specified lines in text file? (68%) How to search and replace text 'ReplaceMe' only in specified lines? (68%) How to search and replace text base on csv file column 1 and 2? (67%) How to batch replace files with specified format in each line? (66%) How to replace specified occurrance of some string to a list of words? (62%) How to replace one specified word with a sequence of words from a file? (61%) How to search and replace with multiple mapping rules by regular expression? (60%) |
Check Demo of Regular expression replace |
Keywords: |
101 control multiply even times unit number filter function number filter replace a string time text file number multiply multiply number regular expression example replace how to multiply file replace first string first string replace string with number function replace |