-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
match_all function to match all occurrences of a regex pattern in a string #3525
Conversation
See also #1491 |
Thanks for pushing this forward. The naming convention in Base is to call this function matchall(re::Regex, str::ByteString)
matches = RegexMatch[]
for m in eachmatch(re, str)
push!(matches, m)
end
return matches
end If there are cases where this doesn't do the same thing, then we need to fix |
Or |
This also defined eltype for RegexMatchIterators, making it possible to write collect(eachmatch(re,str)) for matchall(re,str). See #3525.
|
@StefanKarpinski @JeffBezanson - Thanks for the feedback
I have most of the test cases, will commit them as well. Yes we should fix Tasks for now
Does this look ok? Please let me know if any corrections are neded. |
See #1539 |
Great. Fixing this behavior for RegexMatchIterator is definitely the way to go here. Then |
Sounds good to me. Will fix it and update the PR.
|
Is the RegexMatchIterator going to be updated in a new PR, or is this no longer needed? |
These commits add the ability to match all occurrences of a regex pattern in a given string. (Similar to the perl
/g
option or the rubyscan
)So, now one can search for all matches as follows.
This is an initial pull request and there are still a couple of things pending -