🔗 Perl 6 new regexp rules
Raku rules are the regular expression, string matching and general-purpose parsing facility of Raku, and are a core part of the language. Since Perl's pattern-matching constructs have exceeded the capabilities of formal regular expressions for some time, Raku documentation refers to them exclusively as regexes, distancing the term from the formal definition.
Raku provides a superset of Perl 5 features with respect to regexes, folding them into a larger framework called rules, which provide the capabilities of a parsing expression grammar, as well as acting as a closure with respect to their lexical scope. Rules are introduced with the rule
keyword, which has a usage quite similar to subroutine definitions. Anonymous rules can be introduced with the regex
(or rx
) keyword, or simply be used inline as regexes were in Perl 5 via the m
(matching) or s
(substitution) operators.
Discussed on
- "Perl 6 new regexp rules" | 2009-06-08 | 29 Upvotes 4 Comments