New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex.split modifies the state of the regex #482

Closed
rgrempel opened this Issue Jan 16, 2016 · 4 comments

Comments

Projects
None yet
3 participants
@rgrempel
Contributor

rgrempel commented Jan 16, 2016

Regex.split modifies the state of the regex parameter, because it does not reset the lastIndex property.

This is essentially the same problem that Regex.find had, before the following commit:

jonathanhefner@3fcf583

So, Regex.split essentially needs a similar sort of fix.

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

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.)

Contributor

jvoigtlaender commented Jan 17, 2016

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.)

@rgrempel

This comment has been minimized.

Show comment
Hide comment
@rgrempel

rgrempel Jan 18, 2016

Contributor

Well, it turns out that I can't -- so I'll close this issue!

Contributor

rgrempel commented Jan 18, 2016

Well, it turns out that I can't -- so I'll close this issue!

@rgrempel rgrempel closed this Jan 18, 2016

@rgrempel

This comment has been minimized.

Show comment
Hide comment
@rgrempel

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.

Contributor

rgrempel commented Jan 18, 2016

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 rgrempel reopened this Jan 18, 2016

@evancz evancz referenced this issue Sep 22, 2016

Closed

Regex #722

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Sep 22, 2016

Member

Consolidated regex stuff in #722. Follow along there!

Seems like this could be a PR though.

Member

evancz commented Sep 22, 2016

Consolidated regex stuff in #722. Follow along there!

Seems like this could be a PR though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment