Skip to main content
Version: v6.5.0

Replace-String

Command Description​

Find and replace a substring in the string, and return the replaced string

Command Prototype​

sRet = Replace(sText,sSubText,sReplaceText,bCompare)

Parameter Description​

ParameterRequiredTypeDefaultDescription
sTextTruestring""The string to be operated
sSubTextTruestring""The substring to find and replace
sReplaceTextTruestring""The string used to replace the substring
bCompareTruebooleanNoneWhether to be case sensitive when strings are compared

return​

sRet,The variable used to save the output of the command.

Demo​

TracePrint("----------------------Replace String---------------------- --") 
//-------------------------------------------------------------------------------
//[Remarks] Perform the search and replace operation on the string and return the replaced string.
//Input parameter 1:
// sText--A string to operate on.
//Input parameter 2:
// sSubText--The substring that needs to be searched and replaced.
//Input parameter 3:
// sReplaceText--a string to replace substrings.
//Input parameter 4:
// bCompare--Whether it is case sensitive when comparing strings.
//out parameters:
// sRet--The variable to which the output of the function call is saved.
//
//Command prototype: sRet=Replace(sText,sSubText,sReplaceText,bCompare)
//-------------------------------------------------------------------------------
sRet = Replace ("UsDot", "sD", "iB", true)
TracePrint (sRet)