Named regular expressions
Create named regular expressions:
regex number { \d+ [ '.' \d+ ]? } my $a = "I owe you 3.45 euros"; if ($a ~~ / <number> /) { say $/; } # "3.45"
Combine them:
regex sigil { '$' | '@' | '%' | '&' } regex ident { [ <alpha> | '_' ] \w* } regex name { <ident> [ '::' <ident> ]* } regex variable { <sigil> <name> }