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

Add unpack for RegexMatch #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jonas-schulze
Copy link

@jonas-schulze jonas-schulze commented Apr 23, 2021

This makes it handy to unpack named capture groups from a regex match.

@mauro3
Copy link
Owner

mauro3 commented Apr 23, 2021

Cool, thanks!

I don't use regex much at all. What's your take: is this a complete implementation or will I be chasing edge cases till the end of my life?

@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2021

Codecov Report

Merging #16 (ed242d0) into master (e4bb4b3) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master       #16   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            1         1           
  Lines           31        32    +1     
=========================================
+ Hits            31        32    +1     
Impacted Files Coverage Δ
src/UnPack.jl 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e4bb4b3...ed242d0. Read the comment docs.

@jonas-schulze
Copy link
Author

jonas-schulze commented Apr 23, 2021

The honest answer would be that I don't know; I'm not an expert in Perl-compatible regular expressions. On the flip side, being PCRE and being included in the Julia documentation, among other parts

Captures can also be accessed by indexing the RegexMatch object with the number or name of the capture group:

julia> m=match(r"(?<hour>\d+):(?<minute>\d+)","12:45")
RegexMatch("12:45", hour="12", minute="45")

julia> m[:minute]
"45"

julia> m[2]
"45"

I'd say this is fairly stable and the implementation is complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants