-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
I was playing with Regex.find and I wanted to find all matches for [a-z0-9] so I wrote the regex ([a-z0-9]*).
I wrote it in Elm and ran it in the repl
> (Regex.find Regex.All (regex "([a-z0-9]*)") "simon er en banan en")
[{ match = "simon", submatches = [Just "simon"], index = 0, number = 1 }]
: List Regex.MatchSo this only return one match. I got some help, and after change the regex to [a-z0-9]+ instead of [a-z0-9]* witch now work like I wanted.
I started to wonder if this is a bug or not? I check what would happen if I tested in the browser.
"simon er en banan en".match(/([a-z0-9]*)/g)
=> ["simon", "", "er", "", "en", "", "banan", "", "en", ""]This is not exactly what I wanted but I think the elm method should return the same.
I checked a the source and found that Native/Regex.js#L34 is the line witch stops it from finding more matches. This line was added in https://github.com/elm-lang/core/pull/156 to stop a infinity loop.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels