Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upRegexes are stateful #188
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
evancz
Mar 6, 2015
Member
I think there was a PR that fixes this. Can you take a look at the history of Regex.js to see?
|
I think there was a PR that fixes this. Can you take a look at the history of Regex.js to see? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
|
It looks like https://github.com/elm-lang/core/pull/156 fixed this. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment
Hide comment
evancz
Mar 6, 2015
Member
Cool, thanks for finding it @nathan! Let's close this until it can be reproduced with the latest version of the Regex library.
|
Cool, thanks for finding it @nathan! Let's close this until it can be reproduced with the latest version of the |
evancz
closed this
Mar 6, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
j201 commentedMar 5, 2015
With Elm 0.14.1, running
findon a regex changes its state, possibly causing future calls tofindto act differently. It looks like this is becausefinduses JavaScript'sre.exec, which sets thelastIndexproperty on the regex and makes it ignore matches before that index.Example:
Produces
["1","","True","1"]The first
findprobably setslastIndexto 1, making it ignore the match in the secondfind.containscallsstr.match(re), which clears the regex state, making the lastfindwork.