Rand Stats




This module aims to provide localized variants of built in character classes. It currently only supports the <alpha> class inside of grammars, but support for other classes and outside of grammars. The API is still experimental, so do not (yet) depend on it.


It's as simple as importing the module and adding in the trait is localized.

use Intl::Regex::CharClass

grammar Word is localized('en') {
    token TOP { <alpha>+ }
Word.parse('party');  # party
Word.parse('piñata'); # [no match]

grammar Palabra is localized('es') {
    token TOP { <alpha>+ }
Palabra.parse('piñata'); # piñata
Palabra.parse('fête');   # [no match]

If you do not specify a language, it will by default localized to the system language as defined by User::Language. If for some reason that is not available or detectable, it will default to en (English).

Version history