Regex; Why is here a between difference \p{Katakana} and \x{30A0}-\x{30FF}?

Viewed 50
1 Answers

In \p{Katakana}, \x{30A1}-\x{30FA}\x{30FD}-\x{30FF} is used instead of the \x{30A0}-\x{30FF} range, where \x{30A0}, \x{30FB} and \x{30FC} are excluded.

There is no reason these chars should not have been included because when you use \p{Block=Katakana} Katakana script block Unicode property class you will match all chars in the \x{30A0}-\x{30FF} range.

If you may actually combine the two, [\p{Katakana}\p{Block=Katakana}], you will match all the chars you expect.

If you use ECMAScript regex flavor, the implementation is

\p{scx=Katakana}

See the regex demo. The scx prefix means all indicated script extensions are included:

Scx set contains multiple explicit Script values; Script(cp) is implicit

and

For example, U+30FC KATAKANA-HIRAGANA PROLONGED SOUND MARK is shared across the Hiragana and Katakana scripts, but is not used in other scripts, so it is assigned an scx set value of {Hira Kana}.

Related