Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Published by Scroll Versions from space WBRIDGE and version 7.6.0
Div
Classe2e-refDiv
Rp
Rde
Syntax
Code Block
languagenone
set changed = aString.replace(regExpPattern, replacement)
set changed = replace(LITERAL, regExpPattern, replacement)
SemanticsAll strings that correspond to the regular expression pattern will be replaced with the string replacement. If the pattern does not match, the unchanged string will be returned. Returns a new string. The state of the current string is not changed.
SubstitutablesaString
Can be any variable or object attribute having type String.
,replacement

Can be any variable or object attribute having

the

type String.

Info
iconfalse

In case of capturing groups with the regular expression, replacement may also contain special syntax. This is why replacement will also be interpreted by the Runtime and must not contain unescaped $ and \ signs (see also Replacement Text).
If you are not sure of the contents of your replacement, you can use the replace function itself on the replacement, like

Code Block
set changed = aString.replace(regExpPattern, replacement.replace('\$', '\\\\\$'));
regExpPattern Regular expression (see Regular Expressions for a list of valid regular expressions). An introduction into regular expressions can be found at http://www.regular-expressions.info/.
LITERAL String literal.
Error CodesFind the related error codes on System Errors.
FUSSM/11Cannot execute replace operations on empty strings.
FUSSM/12Cannot construct replace matcher finding occurrences of <string> in <string>.
FUSSM/13Cannot execute replace operations using an empty replace string.
FUSSM/14Cannot compile the regular expression <string> in replace(). Error on line <number>, column <number>.
FUSSM/15Cannot construct replace matcher finding occurrences of <string> in <string>.
FUSSM/16Cannot replace all occurences of <string> in string <string> by <string>.
Examples
Code Block
languagenone
set changed = stringSet.s1.replace("X.+", "A"); 

...