method replace-with

Documentation for method replace-with assembled from the following types:

class Match

From Match

(Match) method replace-with

Defined as:

multi method replace-with(Match:D: Str() $replacement --> Str:D)

Returns the invocant string where the Match object is replaced by $replacement.

my Str $some-string = "Some foo";
my Match $match = $some-string.match(/foo/);
my $another-string = $match.replace-with("string"); # «Some string»