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 upRegex.split modifies the state of the regex #482
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jvoigtlaender
Jan 17, 2016
Contributor
Can you give an example of an Elm program that is affected by this issue? (Same question for https://github.com/elm-lang/core/issues/483 as well.)
|
Can you give an example of an Elm program that is affected by this issue? (Same question for https://github.com/elm-lang/core/issues/483 as well.) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Well, it turns out that I can't -- so I'll close this issue! |
rgrempel
closed this
Jan 18, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rgrempel
Jan 18, 2016
Contributor
Ah, actually I can illustrate the issue, using http://elm-lang.org/try. Here's the problematic example:
import Regex exposing (..)
import Graphics.Element exposing (..)
findComma = regex(",")
main = show
[ split (AtMost 1) findComma "a,b,c,d,e"
, split (AtMost 1) findComma "a,b,c,d,e"
] It produces:
[["a","b,c,d,e"],["b","c,d,e"]]... where one would expect the same result both times.
|
Ah, actually I can illustrate the issue, using http://elm-lang.org/try. Here's the problematic example: import Regex exposing (..)
import Graphics.Element exposing (..)
findComma = regex(",")
main = show
[ split (AtMost 1) findComma "a,b,c,d,e"
, split (AtMost 1) findComma "a,b,c,d,e"
] It produces: [["a","b,c,d,e"],["b","c,d,e"]]... where one would expect the same result both times. |
rgrempel
reopened this
Jan 18, 2016
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
evancz
Sep 22, 2016
Member
Consolidated regex stuff in #722. Follow along there!
Seems like this could be a PR though.
|
Consolidated regex stuff in #722. Follow along there! Seems like this could be a PR though. |
rgrempel commentedJan 16, 2016
Regex.splitmodifies the state of theregexparameter, because it does not reset thelastIndexproperty.This is essentially the same problem that
Regex.findhad, before the following commit:jonathanhefner@3fcf583
So,
Regex.splitessentially needs a similar sort of fix.