R.distinctMatches
This commit is contained in:
@@ -5,3 +5,6 @@
|
||||
match "a"
|
||||
right "bc"))
|
||||
(otherwise (throw "bad match result"))))
|
||||
|
||||
(let [matches (R.distinctMatches "a" "abababab")]
|
||||
(assert (= 4 matches.length)))
|
@@ -70,4 +70,13 @@
|
||||
right
|
||||
(r.matchedRight)
|
||||
group
|
||||
->idx (r.matched idx))))))
|
||||
->idx (r.matched idx))))))
|
||||
|
||||
// Return an array of all non-overlapping matches in the given text, from left-to-right
|
||||
(function :Array<RMatch> distinctMatches [:String regex :String textToSearch &opt :String flags]
|
||||
(let [matches []
|
||||
&mut nextMatch null]
|
||||
(while (set nextMatch (match regex textToSearch flags))
|
||||
(matches.push nextMatch)
|
||||
(set textToSearch nextMatch.right))
|
||||
matches))
|
Reference in New Issue
Block a user