From d175482eff8514034378b8f27d78b765f7f743e6 Mon Sep 17 00:00:00 2001 From: snsmac Date: Mon, 1 Aug 2022 20:38:40 +0200 Subject: [PATCH] Syntax: Make \p{Sc} work 'sc' refers to the 'Currency_Symbol' general category, but is also the abbreviation for the 'Script' property. Fixes #835 Related #719 b1489c8 --- regex-syntax/src/unicode.rs | 4 +++- tests/unicode.rs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/regex-syntax/src/unicode.rs b/regex-syntax/src/unicode.rs index 70d5954b7..a3298e05b 100644 --- a/regex-syntax/src/unicode.rs +++ b/regex-syntax/src/unicode.rs @@ -243,7 +243,9 @@ impl<'a> ClassQuery<'a> { // a general category. (Currently, we don't even support the // 'Case_Folding' property. But if we do in the future, users will be // required to spell it out.) - if norm != "cf" { + // 'sc' refers to the 'Currency_Symbol' general category, but is also + // the abbreviation for the 'Script' property. + if norm != "cf" && norm != "sc" { if let Some(canon) = canonical_prop(&norm)? { return Ok(CanonicalClassQuery::Binary(canon)); } diff --git a/tests/unicode.rs b/tests/unicode.rs index 9b3228624..748bbb79c 100644 --- a/tests/unicode.rs +++ b/tests/unicode.rs @@ -77,6 +77,7 @@ mat!(uni_class_gencat_format, r"\p{Format}", "\u{E007F}", Some((0, 4))); // See: https://github.com/rust-lang/regex/issues/719 mat!(uni_class_gencat_format_abbrev1, r"\p{cf}", "\u{E007F}", Some((0, 4))); mat!(uni_class_gencat_format_abbrev2, r"\p{gc=cf}", "\u{E007F}", Some((0, 4))); +mat!(uni_class_gencat_format_abbrev3, r"\p{Sc}", "$", Some((0, 1))); mat!( uni_class_gencat_initial_punctuation, r"\p{Initial_Punctuation}",