User: editor -- 2010-04-13 << 475 477 >> |
Hits: 3380 |
Type: Count and statistics |
Search all Count and statistics examples |
Description: |
How to count the occurrance of specific pattern in each line of text file? I need to count the occurrance of word like "Yes" in each line of source text file, add the number at the end of each line, and put the result in the output file. |
Input Sample: |
Yes No N/A Yes N/A Yes No N/A No Yes Yes Yes |
Output Sample: |
Yes No N/A Yes 2 N/A Yes No N/A 1 No Yes Yes Yes 3 |
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 * set 'replace unit' to 'Line' * in 'replace with pattern', enter: 3. click 'Replace' button, done. 4. ctrl-s save to output file. Note: function count will count number of the pattern "Yes" appearred in string $match |
Download Script: scripts/476.rst.zip |
Screenshot 1: Replace_Window |
Similar Examples: |
How to replace specific spaces into comma in each line of text file? (71%) How to count the number of specified part in each line? (70%) How to count the occurrance of some specified words in many files? (70%) How do I replace specified lines with each line from a file? (67%) How to count and sort the occurrence of different numbers in a text file? (67%) How to calculate md5 hex value of each line of text file? (67%) How to count the occurrence of a list of words in a text file? (66%) How to insert a line after specific lines in a text file? (65%) |
Check Demo of Count and statistics |
Keywords: |
occurrance specific end of each line match count statistics statist count and statistics ics function string count occurrance specific word add word at the end of each line word add in the end of each line add word to end of line specific line replace with specific replace string with number |