2015-06-11 12:02:27 +10:00
|
|
|
{
|
2015-09-20 17:12:43 +02:00
|
|
|
"name": "replace",
|
|
|
|
"type": "function",
|
2020-07-02 01:46:48 +01:00
|
|
|
"groups": ["String"],
|
2016-10-26 17:41:55 +07:00
|
|
|
"description": "Returns a string with the supplied string, array, or map of strings replaced.",
|
2022-01-07 08:33:29 -05:00
|
|
|
"variants": [{
|
|
|
|
"variant": "String & array variant",
|
|
|
|
"variant_description": "Returns a string with the supplied string or array of strings replaced by a string or an array of strings.",
|
|
|
|
"arguments": [{
|
|
|
|
"arg": "string",
|
|
|
|
"description": "the input string"
|
|
|
|
}, {
|
|
|
|
"arg": "before",
|
|
|
|
"description": "the string or array of strings to replace"
|
|
|
|
}, {
|
|
|
|
"arg": "after",
|
|
|
|
"description": "the string or array of strings to use as a replacement"
|
|
|
|
}],
|
|
|
|
"examples": [{
|
|
|
|
"expression": "replace('QGIS SHOULD ROCK','SHOULD','DOES')",
|
|
|
|
"returns": "'QGIS DOES ROCK'"
|
|
|
|
}, {
|
|
|
|
"expression": "replace('QGIS ABC',array('A','B','C'),array('X','Y','Z'))",
|
|
|
|
"returns": "'QGIS XYZ'"
|
|
|
|
}, {
|
|
|
|
"expression": "replace('QGIS',array('Q','S'),'')",
|
|
|
|
"returns": "'GI'"
|
|
|
|
}]
|
|
|
|
}, {
|
|
|
|
"variant": "Map variant",
|
|
|
|
"variant_description": "Returns a string with the supplied map keys replaced by paired values. Longer map keys are evaluated first.",
|
|
|
|
"arguments": [{
|
|
|
|
"arg": "string",
|
|
|
|
"description": "the input string"
|
|
|
|
}, {
|
|
|
|
"arg": "map",
|
|
|
|
"description": "the map containing keys and values"
|
|
|
|
}],
|
|
|
|
"examples": [{
|
|
|
|
"expression": "replace('APP SHOULD ROCK',map('APP','QGIS','SHOULD','DOES'))",
|
|
|
|
"returns": "'QGIS DOES ROCK'"
|
|
|
|
}, {
|
|
|
|
"expression": "replace('forty two',map('for','4','two','2','forty two','42'))",
|
|
|
|
"returns": "'42'"
|
|
|
|
}]
|
|
|
|
}],
|
|
|
|
"tags": ["array", "map", "strings", "supplied", "replaced"]
|
2015-06-11 12:02:27 +10:00
|
|
|
}
|