Skip to content

Commit 89801f5

Browse files
BenjaminGalliotKristofferC
authored andcommitted
Add test for Unicode named subpatterns and property mixes of scripts and classes. (#40328)
1 parent 73bdd12 commit 89801f5

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

test/regex.jl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,17 @@
9090
@test sprint(show, m) == "RegexMatch(\"xyz\", a=\"x\", 2=\"y\", b=\"z\")"
9191
end
9292

93+
# Unicode named subpatterns and property mixes of scripts and classes (issues #35322/#35459 and #40231)
94+
let m = match(r"(?<numéro>\d)[\pZs]*(?<文本>[\p{Han}\p{P}]+)", "1 孔生雪笠,聖裔也。為人蘊藉,工詩。")
95+
@test haskey(m, :numéro)
96+
@test haskey(m, "文本")
97+
@test !haskey(m, "")
98+
@test (m[:numéro], m[:文本]) == ("1", "孔生雪笠,聖裔也。為人蘊藉,工詩。")
99+
@test (m[1], m[2]) == (m[:numéro], m[:文本])
100+
@test sprint(show, m) == "RegexMatch(\"1 孔生雪笠,聖裔也。為人蘊藉,工詩。\", numéro=\"1\", 文本=\"孔生雪笠,聖裔也。為人蘊藉,工詩。\")"
101+
@test keys(m) == ["numéro", "文本"]
102+
end
103+
93104
# Backcapture reference in substitution string
94105
@test replace("abcde", r"(..)(?P<byname>d)" => s"\g<byname>xy\\\1") == "adxy\\bce"
95106
@test_throws ErrorException replace("a", r"(?P<x>)" => s"\g<y>")

0 commit comments

Comments
 (0)