| User: editor -- 2010-04-13 << 475 477 >> |
| Hits: 494 |
| 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 occurrance of some specified words in many files? (70%) 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%) How to extract all lines with specified date range from text file? (64%) How to count the number of words that start with "ea" in a text file? (64%) |
Check Demo of Count and statistics |
| Keywords: |
| occurrance specific match count statistics statist ics function string result count count occurrance add word at the end of each line word add in the end of each line replace with specific specific line add text to end of line add text end of line replace text number count |