See Original text in context
method subst(Allomorph: |c)
Calls Str.subst
on the invocant's Str
value.
See Original text in context
method subst(|)
Coerces the invocant to Stringy and calls Str.subst.
See Original text in context
multi method subst(Str: , = "", *)
Returns the invocant string where $matcher
is replaced by $replacement
(or the original string, if no match was found). If no $replacement
is provided, the empty string is used (i.e., matched string(s) are removed).
There is an in-place syntactic variant of subst
spelled s/matcher/replacement/
and with adverb following the s
or inside the matcher.
$matcher
can be a Regex
, or a literal Str
. Non-Str matcher arguments of type Cool are coerced to Str
for literal matching. If a Regex
$matcher
is used, the $/
special variable will be set to Nil
(if no matches occurred), a Match
object, or a List of Match
objects (if multi-match options like :g
are used).