Skip to content

Commit 8b6a778

Browse files
Add test for Unicode named subpatterns and property mixes of scripts and classes. (#40328)
1 parent d8b7302 commit 8b6a778

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
@@ -101,6 +101,17 @@
101101
@test keys(m) == ["a", 2, "b"]
102102
end
103103

104+
# Unicode named subpatterns and property mixes of scripts and classes (issues #35322/#35459 and #40231)
105+
let m = match(r"(?<numéro>\d)[\pZs]*(?<文本>[\p{Han}\p{P}]+)", "1 孔生雪笠,聖裔也。為人蘊藉,工詩。")
106+
@test haskey(m, :numéro)
107+
@test haskey(m, "文本")
108+
@test !haskey(m, "")
109+
@test (m[:numéro], m[:文本]) == ("1", "孔生雪笠,聖裔也。為人蘊藉,工詩。")
110+
@test (m[1], m[2]) == (m[:numéro], m[:文本])
111+
@test sprint(show, m) == "RegexMatch(\"1 孔生雪笠,聖裔也。為人蘊藉,工詩。\", numéro=\"1\", 文本=\"孔生雪笠,聖裔也。為人蘊藉,工詩。\")"
112+
@test keys(m) == ["numéro", "文本"]
113+
end
114+
104115
# Backcapture reference in substitution string
105116
@test replace("abcde", r"(..)(?P<byname>d)" => s"\g<byname>xy\\\1") == "adxy\\bce"
106117
@test_throws ErrorException replace("a", r"(?P<x>)" => s"\g<y>")

0 commit comments

Comments
 (0)