Find-Substring-with-Regex
Command Description
Use a Regex to find a string, and return the found substring
Command Prototype
sRet = Regex.FindStr(sText,sPattern,iGroup)
Parameter Description
Parameter | Required | Type | Default | Description |
---|---|---|---|---|
sText | True | string | "" | The string to be operated |
sPattern | True | string | "" | Regular expression |
iGroup | True | number | 0 | Returns the matching result of the first subexpression. 0 means to return the whole matching string |
return
sRet,The variable used to save the output of the command.
Demo
TracePrint("----------------------Regular expression find substring------------------- -----")
//-------------------------------------------------------------------------------
//[Remarks] The regular expression searches for a string and returns the found substring of the string.
//Input parameter 1:
// sText--A string to operate on.
//Input parameter 2:
// sPattern--regular expression.
//Input parameter 3:
// iGroup--Return the matching result of the first sub-expression, 0 means return the entire matched string.
//out parameters:
// sRet--The variable to which the output of the function call is saved.
//
//Command prototype: sRet=Regex.FindStr(sText,sPattern,iGroup)
//-------------------------------------------------------------------------------
sRet=Regex.FindStr("UiBot123","[0-9]{3}",0)
TracePrint (sRet)