Finds the first pattern match in a string.
Result = SRP_Regex("Search", String, Pattern)
Returns
A structure containing information on the match, if found, or "" if not found.
Parameters
Parameter | Description |
---|---|
String | The target string to be pattern matched. (REQUIRED) |
Pattern | The regex pattern. (REQUIRED) |
Remarks
The Search service looks for a match within a string. If found, it returns the following @FM delimited structure:
Pos | Name | Description |
---|---|---|
<1> | String | The actual substring matching the pattern. |
<2> | Pos | The starting position of the match within the original string. |
<3> | Length | The length of the match. |
<4> | Captures | An @VM delimited list of captured groups. (You can learn more about capturing groups here.) |
If you don't care about all this information and just want the matched string, use the Extract service instead.
Examples
// find the phone number String = 'Call 800-555-1212 for info' Pattern = '((\d{3})(?:\.|-))?(\d{3})(?:\.|-)(\d{4})' Result = SRP_Regex("Search", String, Pattern) // we can get the whole number, or... PhoneNumber = Result<1> // we can get the parts because we captured them with parenthesis AreaCode = Result<4, 2> ExchangeCode = Result<4, 3> LineNumber = Result<4, 4>