method subst-mutate

Documentation for method subst-mutate, assembled from the following types:

class Str

From Str

(Str) method subst-mutate

Where subst returns the modified string and leaves the original unchanged, it is possible to mutate the original string by using subst-mutate. If the match is successful, the method returns a Match object representing the successful match, otherwise returns Nil. If :nth (or one of its aliases) with Iterable value, :g, :global, or :x arguments are used, returns a List of Match objects, or an empty List if no matches occurred.

my $some-string = "Some foo";
my $match = $some-string.subst-mutate(/foo/"string");
say $some-string;  # OUTPUT: «Some string␤» 
say $match;        # OUTPUT: «「foo」␤» 
$some-string.subst-mutate(/<[oe]>/'':g); # remove every o and e, notice the :g named argument from .subst