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

ParameterDescription
StringThe target string to be pattern matched. (REQUIRED)
PatternThe regex pattern. (REQUIRED)

Remarks

The Search service looks for a match within a string. If found, it returns the following @FM delimited structure:

PosNameDescription
<1>
StringThe actual substring matching the pattern.
<2>
PosThe starting position of the match within the original string.
<3>
LengthThe length of the match.
<4>
CapturesAn @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>
  • No labels