In Allomorph§

See primary documentation in context for method subst

method subst(Allomorph:D: |c)

Calls Str.subst on the invocant's Str value.

In Str§

See primary documentation in context for method subst

multi method subst(Str:D: $matcher$replacement = ""*%options)

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).

In Cool§

See primary documentation in context for method subst

method subst(|)

Coerces the invocant to Stringy and calls Str.subst.