Skip to main content

Replacing a Substring

Replacing a Substring

You can use $WEXTRACT with the SET command to replace a specified character or range of characters with another value. You can also use it to append characters to the end of a string. SET $WEXTRACT counts a surrogate pair as a single character.

When $WEXTRACT is used with SET on the left hand side of the equals sign, string can be a valid variable name. If the variable does not exist, SET $WEXTRACT defines it. The string argument can also be a multidimensional property reference; it cannot be a non-multidimensional object property. Attempting to use SET $WEXTRACT on a non-multidimensional object property results in an <OBJECT DISPATCH> error.

You cannot use SET (a,b,c,...)=value syntax with $WEXTRACT (or $EXTRACT, $PIECE, or $LIST) on the left of the equals sign, if the function uses relative offset syntax: * representing the end of a string and *-n or *+n representing relative offset from the end of the string. You must instead use SET a=value,b=value,c=value,... syntax.

For further details on replacing a substring, refer to the $EXTRACT function.

FeedbackOpens in a new tab