Skip to content

Commit

Permalink
return a Vector from keys(::RegexMatch)
Browse files Browse the repository at this point in the history
correct test of RegexMatch keys
  • Loading branch information
oxinabox committed Nov 13, 2020
1 parent 4a98e23 commit 3a5a603
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion base/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ end

function keys(m::RegexMatch)
idx_to_capture_name = PCRE.capture_names(m.regex.regex)
return ntuple(length(m.captures)) do i
return map(eachindex(m.captures)) do i
# If the capture group is named, return it's name, else return it's index
get(idx_to_capture_name, i, i)
end
Expand Down
2 changes: 1 addition & 1 deletion test/regex.jl
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
@test !haskey(m, "foo")
@test (m[:a], m[2], m["b"]) == ("x", "y", "z")
@test sprint(show, m) == "RegexMatch(\"xyz\", a=\"x\", 2=\"y\", b=\"z\")"
@test keys(m) = (:a, 2, :b)
@test keys(m) == [:a, 2, :b]
end

# Backcapture reference in substitution string
Expand Down

0 comments on commit 3a5a603

Please sign in to comment.