Method replace()
- Method replace
stringreplace(strings,stringfrom,stringto)
stringreplace(strings,array(string)from,array(string)to)
stringreplace(strings,array(string)from,stringto)
stringreplace(strings,mapping(string:string)replacements)
arrayreplace(arraya,mixedfrom,mixedto)
mappingreplace(mappinga,mixedfrom,mixedto)- Description
Generic replace function.
This function can do several kinds replacement operations, the different syntaxes do different things as follows:
If all the arguments are strings, a copy of
swith every occurrence offromreplaced withtowill be returned. Special case:towill be inserted between every character insiffromis the empty string.If the first argument is a string, and the others array(string), a string with every occurrance of
from[i] insreplaced withto[i] will be returned. Instead of the arraysfromandtoa mapping equvivalent tomkmapping(can be used.from,to)If the first argument is an array or mapping, the values of
awhich are `==() withfromwill be replaced withtodestructively.awill then be returned.- Note
Note that replace() on arrays and mappings is a destructive operation.