Skip to content
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

Issue with eachmatch #26199

Closed
bdeonovic opened this issue Feb 25, 2018 · 5 comments · Fixed by #26831
Closed

Issue with eachmatch #26199

bdeonovic opened this issue Feb 25, 2018 · 5 comments · Fixed by #26831
Labels
bug Indicates an unexpected problem or unintended behavior strings "Strings!"

Comments

@bdeonovic
Copy link
Contributor

bdeonovic commented Feb 25, 2018

I wrote this simple regex to grab words (with possible fancy characters)

for m in eachmatch(r"(\p{L}+)", "testing you")
       @show m
end
m = RegexMatch("testing", 1="testing")
m = RegexMatch("you", 1="you")

seems to work:

prompt="¿Cuál es tu pregunta?"
"¿Cuál es tu pregunta?"

Main> for m in eachmatch(r"(\p{L}+)", prompt)
              @show m
       end
m = RegexMatch("Cuál", 1="Cuál")
m = RegexMatch("es", 1="es")
m = RegexMatch("tu", 1="tu")
m = RegexMatch("pregunta", 1="pregunta")

but it doesn't????

prompt = "Tú lees."
for m in eachmatch(r"(\p{L}+)", prompt)
       @show m
end
ERROR: ArgumentError: invalid SubString index
Stacktrace:
 [1] SubString{String}(::String, ::Int64, ::Int64) at .\strings\types.jl:17
 [2] match(::Regex, ::String, ::Int64, ::UInt32) at .\regex.jl:166
 [3] next(::Base.RegexMatchIterator, ::RegexMatch) at .\regex.jl:343
 [4] anonymous at .\<missing>:?
 [5] eval(::Module, ::Any) at .\boot.jl:235
end

(warning infinite loop): if you try

prompt = ""
for m in eachmatch(r"(\p{L}+)", prompt)
       @show m
end
m = RegexMatch("", 1="")
m = RegexMatch("", 1="")
m = RegexMatch("", 1="")
m = RegexMatch("", 1="")
m = RegexMatch("", 1="")
m = RegexMatch("", 1="")
m = RegexMatch("", 1="")
m = RegexMatch("", 1="")
m = RegexMatch("", 1="")
......................
@bdeonovic
Copy link
Contributor Author

bdeonovic commented Feb 25, 2018

works with match and matchall but not eachmatch

match(r"(\p{L}+)", prompt)
RegexMatch("", 1="")

matchall(r"(\p{L}+)", prompt)
2-element Array{SubString{String},1}:
 ""
 "lees"

@bdeonovic bdeonovic changed the title PCRE Regex invalid substring Issue with eachmatch Feb 25, 2018
@bdeonovic
Copy link
Contributor Author

bdeonovic commented Feb 25, 2018

On slack @ChrisRackauckas said this was fixed on master so I will go ahead and close.

@ChrisRackauckas
Copy link
Member

I think that you mixed up something I said about a change I did to DiffEq master with this. I never referenced this.

@bdeonovic bdeonovic reopened this Feb 27, 2018
@bdeonovic
Copy link
Contributor Author

Hahaha, I guess I misinterpreted to whom you were responding to!

@JeffBezanson JeffBezanson added bug Indicates an unexpected problem or unintended behavior strings "Strings!" labels Mar 6, 2018
@stevengj
Copy link
Member

The same issue as #26829, with the same fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior strings "Strings!"
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants