subst
ErrorsCollection

subst

Synthesised documentation from type/Allomorph type/Cool type/Str

From type/Allomorph

See Original text in context

method subst(Allomorph:D: |c)

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

From type/Cool

See Original text in context

method subst(|)

Coerces the invocant to Stringy and calls Str.subst.

From type/Str

See Original text in context

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