Jump to content

Count occurrences of a substring: Difference between revisions

m
no edit summary
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). ; add the SUBSTRING we found to the list of 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
31

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.