Function: s-count-matches
s-count-matches is a byte-compiled function defined in s.el.
Signature
(s-count-matches REGEXP S &optional START END)
Documentation
Count occurrences of regexp in s.
start, inclusive, and end, exclusive, delimit the part of s to
match. start and end are both indexed starting at 1; the initial
character in s is index 1.
This function starts looking for the next match from the end of the
previous match. Hence, it ignores matches that overlap a previously
found match. To count overlapping matches, use
s-count-matches-all.
Source Code
;; Defined in ~/.emacs.d/elpa/s-20220902.1511/s.el
(defun s-count-matches (regexp s &optional start end)
"Count occurrences of `regexp' in `s'.
`start', inclusive, and `end', exclusive, delimit the part of `s' to
match. `start' and `end' are both indexed starting at 1; the initial
character in `s' is index 1.
This function starts looking for the next match from the end of the
previous match. Hence, it ignores matches that overlap a previously
found match. To count overlapping matches, use
`s-count-matches-all'."
(declare (side-effect-free t))
(save-match-data
(with-temp-buffer
(insert s)
(goto-char (point-min))
(count-matches regexp (or start 1) (or end (point-max))))))