September 2017
Beginner
402 pages
9h 52m
English
Characters in Unicode belong to different categories, such as letters or digits, or punctuation. Categories may have additional levels of detailization, for example letters can be lowercase or uppercase.
Regexes in Perl 6 provide us with a mechanism of character classes based on Unicode categories. To create such a class, use a pair of angle brackets, containing a semicolon followed by a capital first letter of the category name. To specify the subcategory, add a corresponding lowercase letter.
For example, the character class matching letters is <:L>, while the class for the uppercase letters is <:Lu>. In the following example we match a few letters against these character classes:
for <A a B b Ω ω 1 2 * ^ > -> $char ...
Read now
Unlock full access