From 918298d4cd0c6e5c2187742b1f6b2363cbded892 Mon Sep 17 00:00:00 2001 From: Benjamin Galliot Date: Tue, 6 Apr 2021 18:21:48 +0200 Subject: [PATCH] Backport 1.6 of PR #40328. --- test/regex.jl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/regex.jl b/test/regex.jl index 76fecfb4e4f56..bc8506b17999b 100644 --- a/test/regex.jl +++ b/test/regex.jl @@ -90,6 +90,16 @@ @test sprint(show, m) == "RegexMatch(\"xyz\", a=\"x\", 2=\"y\", b=\"z\")" end + # Unicode named subpatterns and property mixes of scripts and classes (issues #35322/#35459 and #40231) + let m = match(r"(?\d)[\pZs]*(?<文本>[\p{Han}\p{P}]+)", "1 孔生雪笠,聖裔也。為人蘊藉,工詩。") + @test haskey(m, :numéro) + @test haskey(m, "文本") + @test !haskey(m, "ゑ") + @test (m[:numéro], m[:文本]) == ("1", "孔生雪笠,聖裔也。為人蘊藉,工詩。") + @test (m[1], m[2]) == (m[:numéro], m[:文本]) + @test sprint(show, m) == "RegexMatch(\"1 孔生雪笠,聖裔也。為人蘊藉,工詩。\", numéro=\"1\", 文本=\"孔生雪笠,聖裔也。為人蘊藉,工詩。\")" + end + # Backcapture reference in substitution string @test replace("abcde", r"(..)(?Pd)" => s"\gxy\\\1") == "adxy\\bce" @test_throws ErrorException replace("a", r"(?P)" => s"\g")