Count occurrences of a substring: Difference between revisions
m
no edit summary
m (→{{header|ALGOL 68}}: typo) |
mNo edit summary |
||
Line 1,561:
(let ((substrings)) ; empty list to add occurrences of SUBSTRING as we find them
(while (string-match substring text) ; as long as we can find SUBSTRING in TEXT
(push (match-string 0 text) substrings)
(setq text (replace-match "" nil nil text))) ; remove SUBSTRING from text, and repeat while loop
(length substrings))) ; count number of items in substrings list
|