Regular-Expression-Matching
Command Description
Replace the string with the regular expression and returns the result of the replaced string
Command Prototype
sRet = Regex.Replace(sText,sPattern,sNew,nCount)
Parameter Description
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
sText | True | string | "" | The string to be replaced |
sPattern | True | string | "" | Regular expression |
sNew | True | string | "" | The content matched by the regular expression in the target string will be replaced with this text |
nCount | True | number | 0 | The maximum number of pattern replacement. Default 0 means Replace all |
return
sRet,The variable used to save the output of the command.
Demo
TracePrint("----------------------Regular expression replacement--------------------- ---")
//-------------------------------------------------------------------------------
//[Remarks] The regular expression replaces the string and returns the replaced string result.
//Input parameter 1:
// sText--A string to operate on.
//Input parameter 2:
// sPattern--regular expression.
//Input parameter 3:
// sNew--The content matched by the regular expression in the target string will be replaced with this text.
//Input parameter 4:
// nCount--The maximum number of replacements after pattern matching, the default 0 means to replace all matches.
//out parameters:
// sRet--The variable to which the output of the function call is saved.
//
//Command prototype: sRet=Regex.Replace(sText,sPattern,sNew,nCount)
//-------------------------------------------------------------------------------
sRet=Regex.Replace("UiBot123","\\d{3}","RPA",0)
TracePrint (sRet)