Function: s-matched-positions-all

s-matched-positions-all is a byte-compiled function defined in s.el.

Signature

(s-matched-positions-all REGEXP STRING &optional SUBEXP-DEPTH)

Documentation

Return a list of matched positions for REGEXP in STRING.

SUBEXP-DEPTH is 0 by default.

Source Code

;; Defined in ~/.emacs.d/elpa/s-20220902.1511/s.el
(defun s-matched-positions-all (regexp string &optional subexp-depth)
  "Return a list of matched positions for REGEXP in STRING.
SUBEXP-DEPTH is 0 by default."
  (declare (side-effect-free t))
  (if (null subexp-depth)
      (setq subexp-depth 0))
  (save-match-data
    (let ((pos 0) result)
      (while (and (string-match regexp string pos)
                  (< pos (length string)))
        (push (cons (match-beginning subexp-depth) (match-end subexp-depth)) result)
        (setq pos (match-end 0)))
      (nreverse result))))