Method replace()
- Method
replace
arrayreplace(arraya,mixedfrom,mixedto)
mappingreplace(mappinga,mixedfrom,mixedto)- Description
Generic replace function (arrays and mappings).
If the first argument is an array or mapping, the values of a which are `==() with from will be replaced with to destructively. a will then be returned.
- Note
Note that replace() on arrays and mappings is a destructive operation.
- 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)- Description
Generic replace function (strings).
- Parameter
s Source string to perform the replacements on.
- Parameter
from Sub-string or strings to match verbatim.
- Parameter
to - Parameter
replacements Instead of the arrays from and to a mapping equivalent to
mkmapping(from, to)can be used.Replaces all occurrances of from in s with the corresponding to.
If all the arguments are strings, a copy of s with every occurrence of from replaced with to will be returned. Special case: to will be inserted between every character in s if from is the empty string.
If the first argument is a string, and the others array(string), a string with every occurrance of from[i] in s replaced with to[i] will be returned.