quote s/ / /
Documentation for quote s/ / /, assembled from the following types:
Substitutions are written similarly to matching, but the substitution operator has both an area for the regex to match, and the text to substitute:
s/replace/with/; # a substitution that is applied to $_~~ s/replace/with/; # a substitution applied to a scalar
The substitution operator allows delimiters other than the slash:
Note that neither the colon
: nor balancing delimiters such as
() can be substitution delimiters. Colons clash with adverbs such as
s:i/Foo/bar/ and the other delimiters are used for other purposes.
If you use balancing brackets, the substitution works like this instead:
s[replace] = 'with';
The right-hand side is now a (not quoted) Perl 6 expression, in which
$/ is available as the current match:
= 'some 11 words 21';s:g[ \d+ ] = 2 * $/;.say; # OUTPUT: «some 22 words 42␤»
m// operator, whitespace is ignored in the regex part of a substitution. Comments, as in Perl 6 in general, start with the hash character
# and go to the end of the current line.