Replaces text in a container with other text.
Built-in Message handler[]
Syntax:
replace <oldString> with <newString> in <container>
Examples:
replace "A" with "N" in thisVariable -- changes all As to Ns
replace return with empty in field 1 -- runs lines together
replace oldText with "\" in it
replace ".com" with newText in URL "file:text.txt"
Use the replace command to replace all instances of one string with another string.
The replace command is faster than the replaceText function, but does not support regular expressions: you can replace only an exact string of text.
You can use the replace command on a field, but doing so removes any formatting (fonts, styles, colors, and sizes) in the field. To preserve existing styling in fields use the replace in field command.
Parameters:
- oldString (string): Any expression that evaluates to a string, and specifies the text to replace.
- newString (string): Any expression that evaluates to a string, and specifies the text to replace the oldString with.
- container: A field, button, or variable, or the message box.
See also: replace in field (command), replaceText (function), field (object),