Skip to content

Commit c0e43af

Browse files
committed
return a Vector from keys(::RegexMatch)
correct test of RegexMatch keys
1 parent 7a22050 commit c0e43af

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

base/regex.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ end
141141

142142
function keys(m::RegexMatch)
143143
idx_to_capture_name = PCRE.capture_names(m.regex.regex)
144-
return ntuple(length(m.captures)) do i
144+
return map(eachindex(m.captures)) do i
145145
# If the capture group is named, return it's name, else return it's index
146146
get(idx_to_capture_name, i, i)
147147
end

test/regex.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
@test !haskey(m, "foo")
8282
@test (m[:a], m[2], m["b"]) == ("x", "y", "z")
8383
@test sprint(show, m) == "RegexMatch(\"xyz\", a=\"x\", 2=\"y\", b=\"z\")"
84-
@test keys(m) = (:a, 2, :b)
84+
@test keys(m) == [:a, 2, :b]
8585
end
8686

8787
# Backcapture reference in substitution string

0 commit comments

Comments
 (0)