PCRE2Project / pcre2

PCRE2 development is now based here.
Other
922 stars 194 forks source link

Support for Unicode blocks #242

Open BenjaminGalliot opened 1 year ago

BenjaminGalliot commented 1 year ago

It would be nice to be able to match Unicode blocks (like \p{Block=Combining_Diacritical_Marks} or \p{Block=CJK_Symbols_and_Punctuation}). I did not find a way to do it without using ranges…

From https://www.regular-expressions.info/unicode.html :

Unicode Blocks

The Unicode standard divides the Unicode character map into different blocks or ranges of code points. Each block is used to define characters of a particular script like “Tibetan” or belonging to a particular group like “Braille Patterns”. Most blocks include unassigned code points, reserved for future expansion of the Unicode standard.

Note that Unicode blocks do not correspond 100% with scripts. An essential difference between blocks and scripts is that a block is a single contiguous range of code points, as listed below. Scripts consist of characters taken from all over the Unicode character map. Blocks may include unassigned code points (i.e. code points matched by \p{Cn}). Scripts never include unassigned code points. Generally, if you’re not sure whether to use a Unicode script or Unicode block, use the script.

[…]

The actual names of the blocks are the same in all regular expression engines. The block names are defined in the Unicode standard. PCRE and PHP do not support Unicode blocks, even though they support Unicode scripts.