summaryrefslogtreecommitdiff
path: root/s.el
diff options
context:
space:
mode:
authorGeoff Gole <geoffgole@gmail.com>2013-06-17 15:17:43 +0800
committerGeoff Gole <geoffgole@gmail.com>2013-06-17 15:17:43 +0800
commit7c654df4e79e1e33e4207504524b0ab21d9c7209 (patch)
treec7c851752828f9a76b83550ed433d298c1763dee /s.el
parent6d6dd2f26c20650fd2b9721b155e9143163acc93 (diff)
Include overlapping matches in s-match-strings-all
Diffstat (limited to 's.el')
-rw-r--r--s.el14
1 files changed, 7 insertions, 7 deletions
diff --git a/s.el b/s.el
index 0eb57c6..0dac2f5 100644
--- a/s.el
+++ b/s.el
@@ -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))