Substitutes
Substitute(old, new), Substitute(STACK, STACK), Substitute(old, STACK), Substitute (STACK, new)
parameters: character string 'old' must be replaced by 'new
Stack | Position | Description |
---|---|---|
Stack(In) | Top | any |
Stack(Out) | Top | a character string |
Any data from the stack top is transformed into a character string, which is then searched for the substring 'old'. Each occurrence of 'old' is replaced by 'new' (further examples).
Note: Instead of Substitute it is better to use CX_STRING։։Replace, this also allows multiple substitutions in one call.
Example
"hello world" Substitute("world", "moon") // Result: "hello moon"
// The stack version:
"hello world" "world" "moon" Substitute(STACK, STACK) // Result: "hello moon"
// Always replaces all occurences:
"hello world, hello moon" Substitute("hello", "good night") // Result: "good night world, good night moon"
See also