Replace

Top  Previous  Next

 

The Replace Special Function Command allows you to replace specified characters within a string with other specified characters.

lamp Important: Special Function commands can only be used on the right hand side of a Variable Assignment command.

Command Syntax

 

Replace,[OriginalString],[SearchFor],[ReplaceWith]

 

The comma character after the command is compulsory as are all three parameters and the commas separating them.

 

Parameters:

 

OriginalString: The string to be modified

SearchFor: The string to search for within the original string

ReplaceWith: The string to use to replace the SearchFor string if it is found

 

All three parameters are compulsory. If any required parameter is missing or invalid an error will be thrown. All parameters must be surrounded by quotation marks if one or more commas are included. It is good practice to include the quotation marks in any case, so that it reduces the risk of error when writing scripts. All instances of the SearchFor value will be replaced. If the string contains no instances of the SearchFor value the original string will be returned unchanged.

lamp Important: Any string containing or consisting of one or more commas MUST be enclosed in double quotes, otherwise an error will be thrown. To remove text from a string specify a pair of double quotes as the ReplaceWith parameter.

Example:

 

Replace a misspelt word with the correct one

 

Var:NewSentence=Replace,This is a test sting,sting,string

 

Remove commas from a string

 

Var:NoCommas=Replace,"This, is, a, test, string with no commas",",",""

 

See Also: Special Functions Substring GetFileVersion