SETREPLACE - Replace a substring with another substring

Top  Previous  Next

Syntax:

SETREPLACE

[ variable ]  =  [ source ] [ old substring ] [ new substring ]

Arguments:

[ variable ]

Variable to assign; if the variable does not previously exist it is created.

 

[ source ]

Variable or string containing the full original source string.

 

[ old substring ]

Variable or string defining the substring to be replaced.

 

[ new substring ]

Variable or string defining the replacement value.

Options:

/ignorecase

Ignore character case in source string when scanning for matching substrings.

 

 

This script command scans the [ source ] string and replaces all instances of the [ old substring ] with [ new substring ] and saves the result in [ variable ].

 

Consider the following example.

 

SET string = "This is a string."

SETREPLACE mine = string " a " " my "

 

The resulting mine variable contains the value "This is my string.". The original string variable is unchanged.

 

 

Related command(s):        SETLEFT, SETMID, SETRIGHT, SETLEN, SETEXTRACT, SETSUBSTR, SET