I wonder how to precompile a regular expression for a range such as [A-B]
.
Given a character "A\u{20DD}"
(LATIN CAPITAL LETTER A
+ COMBINING ENCLOSING CIRCLE
).
print(Character("A\u{20DD}") > Character("A")) // -> true
print(Character("A\u{20DD}") < Character("B") ) // -> true
let regex = /([A-B])/
switch "A\u{20DD}" {
case let something <- regex:
// What is the type of `something`?
}
-
something
would beCharacter("A\u{20DD}")
when applied with grapheme-cluster semantics. -
something
would beUnicode.Scalar("A")
when applied with scalar semantics.
However, at the point of declaration let regex = /([A-B])/
, it is impossible to determine whether A
and B
are Character
s or Unicode.Scalar
s.