MatchAllGroups - cRegEx
Finds all individual matching groups and returns them in a two dimensional array
Type: Function
Return Data Type: String[][]
Parameters
| Parameter | Type | Description |
|---|---|---|
| sSubject | String | The host string to run the regular expression on |
Syntax
Function MatchAllGroups String sSubject Returns String[][]
Call Example
Get MatchAllGroups sSubject to String[][]Variable
Description
Finds all individual matching groups and returns them in a two-dimensional array.
Returns a two dimensional string array containing all matches and their matching groups. The first dimension represents the full match, and the first item on the second dimension is the full match value. Then for each matching group two items are added on the second dimension being the name and the value.
Sample
The example below shows how to filter the relevant information out of an ini file using a single regular expression.
Handle hoRegEx
String[][] aIniData
Get Create (RefClass(cRegEx)) to hoRegEx
Set psExpression of hoRegEx to "\[(?<sectionheader>.*)\]|(?<key>.+)=(?<value>[^#;\r\n]*)"
Get MatchAllGroups of hoRegEx """
[Properties]
Version=25.0
[WorkspacePaths]
ConfigFile=.\Programs\Config.ws
[Preferences]
DefaultFormHeight=12
""" to aIniData
Send Destroy of hoRegEx
The contents of aIniData will be:
aIniData[0][0] = "[Properties]"
aIniData[0][1] = "sectionheader"
aIniData[0][2] = "Properties"
aIniData[1][0] = "Version=25.0"
aIniData[1][1] = "key"
aIniData[1][2] = "Version"
aIniData[1][3] = "value"
aIniData[1][4] = "25.0"
Return Value
Two-dimensional array of individual matching groups.