In Regexes§
See primary documentation in context for Regex adverbs.
The adverbs that appear at the time of a regex declaration are part of the actual regex and influence how the Raku compiler translates the regex into binary code.
For example, the :ignorecase (:i) adverb tells the compiler to ignore the distinction between uppercase, lowercase, and titlecase letters.
So 'a' ~~ /A/ is false, but 'a' ~~ /:i A/ is a successful match.
Regex adverbs can come before or inside a regex declaration and only affect the part of the regex that comes afterwards, lexically. Note that regex adverbs appearing before the regex must appear after something that introduces the regex to the parser, like 'rx' or 'm' or a bare '/'. This is NOT valid:
my $rx1 = :i/a/; # adverb is before the regex is recognized => exception
but these are valid:
my $rx1 = rx:i/a/; # before my $rx2 = m:i/a/; # before my $rx3 = /:i a/; # inside
These two regexes are equivalent:
my $rx1 = rx:i/a/; # before my $rx2 = rx/:i a/; # inside
Whereas these two are not:
my $rx3 = rx/a :i b/; # matches only the b case insensitively my $rx4 = rx/:i a b/; # matches completely case insensitively
Square brackets and parentheses limit the scope of an adverb:
/ (:i a b) c /; # matches 'ABc' but not 'ABC' / [:i a b] c /; # matches 'ABc' but not 'ABC'
Alternations and conjunctions, and their branches, have no impact on the scope of an adverb:
/ :i a | b c /; # matches 'a', 'A', 'bc', 'Bc', 'bC' or 'BC' / [:i a | b] c /; # matches 'ac', 'Ac', 'bc', or 'Bc' but not 'aC', 'AC', 'bC' or 'BC'
When two adverbs are used together, they each keep their colon at the front:
"þor is Þor" ~~ m:g:i/þ/; # OUTPUT: «(「þ」 「Þ」)»
That implies that when there are multiple characters together after a :, they correspond to the same adverb, as in :ov or :P5.