replace

# given 'Hello World'

$string->replace('World', 'Universe'); # Hello Universe
$string->replace('world', 'Universe', 'i'); # Hello Universe
$string->replace(qr/world/i, 'Universe'); # Hello Universe
$string->replace(qr/.*/, 'Nada'); # Nada

The replace method performs a smart search and replace operation and returns the modified string (if any modification occurred). This method optionally takes a replacement modifier as it's final argument. Note, this operation expects the 2nd argument to be a replacement String. This method returns a string object.

replace(Str $arg1, Str $arg2) : StrObject

method

5 POD Errors

The following errors were encountered while parsing the POD:

Around line 10:

Unknown directive: =name

Around line 14:

Unknown directive: =usage

Around line 23:

Unknown directive: =description

Around line 31:

Unknown directive: =signature

Around line 35:

Unknown directive: =type