Parameter | Type | Description |
---|---|---|
STRING | VALUE(STRING) | The string to search in. |
SEQUENCE | VALUE(STRING) | The character sequence to search for. |
REPLACEMENT | VALUE(STRING) | The string to replace the sets of found characters with. |
VALUE(STRING) | The resultant string from replacing every found sequence of characters with the replacement. |
This function searches the first string for every sequence of characters and, when found, replaces each sequence with the replacement string, and returns the result. All provided values are interpreted as strings before the check. The check is case-sensitive.
If no occurrences of the provided search sequence are found, the original string is returned.
a = strReplaceAll("tomato", "to", "__"); // a = "__ma__"
a = strReplaceAll("Apples to Apples", "Apples", "Grapes"); // a = "Grapes to Grapes"
a = strReplaceAll(12345, 12, "__"); // a = "__345"
a = strReplaceAll(100.003, "00", "__"); // a = "1__.__3"
a = strReplaceAll("ABCDEFG", "a", "_"); // a = "ABCDEFG"
world
{
start()
{
// Replace
textln(strReplace("Apples and Pears", "Apples", "Oranges"));
textln(strReplace("Apples and Apples", "Apples", "Oranges"));
textln(strReplace("Kiwis and Lemons", "Grapefruits", "Peaches"));
textln(strReplace(100, 0, "Zero"));
textln("");
// Replace Last
textln(strReplaceLast("Apples and Pears", "Apples", "Oranges"));
textln(strReplaceLast("Apples and Apples", "Apples", "Oranges"));
textln(strReplaceLast("Kiwis and Lemons", "Grapefruits", "Peaches"));
textln(strReplaceLast(100, 0, "Zero"));
textln("");
// Replace All
textln(strReplaceAll("Apples and Pears", "Apples", "Oranges"));
textln(strReplaceAll("Apples and Apples", "Apples", "Oranges"));
textln(strReplaceAll("Kiwis and Lemons", "Grapefruits", "Peaches"));
textln(strReplaceAll(100, 0, "Zero"));
quit;
}
}