re-seq creates too many matches

Description

From https://ask.clojure.org/index.php/8329/caret-character-differences-with-re-seq-in-cljs-vs-clj :

Problem: From Dominic's answer: "recurses into re-seq with the remainder of the string, doing this means that ^[a-f] will match again against this new, shorter, string."

Environment

None

Activity

Show:
Lauri Oherd
May 16, 2020, 4:20 PM
Edited

Solution in patch: add global flag to regular expression if there isn’t already and call repeatedly RegExp.prototype.exec() method until there are no more matches.

There is a need to check with each match if it’s length is zero in order to avoid an infinite loop.

Assignee

Lauri Oherd

Reporter

Alex Miller

Labels

None

Approval

None

Patch

Code and Test

Affects versions

Priority

Major