diff options
author | Geoff Gole <geoffgole@gmail.com> | 2013-06-17 15:17:43 +0800 |
---|---|---|
committer | Geoff Gole <geoffgole@gmail.com> | 2013-06-17 15:17:43 +0800 |
commit | 7c654df4e79e1e33e4207504524b0ab21d9c7209 (patch) | |
tree | c7c851752828f9a76b83550ed433d298c1763dee /s.el | |
parent | 6d6dd2f26c20650fd2b9721b155e9143163acc93 (diff) |
Include overlapping matches in s-match-strings-all
Diffstat (limited to 's.el')
-rw-r--r-- | s.el | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -353,16 +353,16 @@ attention to case differences." (apply 'string (nreverse (string-to-list s)))) (defun s-match-strings-all (regex string) - "Return a list of every match for REGEX in STRING. + "Return a list of matches for REGEX in STRING. -Each element itself is a list of matches, as per `match-string'." - (let (all-strings - (i 0)) +Each element itself is a list of matches, as per +`match-string'. Multiple matches at the same position will be +ignored after the first." + (let ((all-strings ()) + (i 0)) (while (and (< i (length string)) (string-match regex string i)) - (if (= (match-end 0) i) - (setq i (1+ i)) - (setq i (match-end 0))) + (setq i (1+ i)) (let (strings (num-matches (/ (length (match-data)) 2)) (match 0)) |