RegularExpressionGroup()
Syntax
Result$ = RegularExpressionGroup(#RegularExpression, Group)Description
Extract the string matched by a group within the regular expression after a call to NextRegularExpressionMatch().
Parameters
#RegularExpression The regular expression to use. ExamineRegularExpression() and NextRegularExpressionMatch() must have been called on this regular expression. Group The index of the group to extract. The first group has index 1.
Return value
Returns the string matched by the regular expression group.
Remarks
Groups in a regular expression are defined by surrounding a sub-expression with braces "(" and ")". The groups are numbered as they appear in the regular expression from left to right. The first group has index 1. The CountRegularExpressionGroups() function can be used to find out the number of groups in a regular expression.
As an alternative, the RegularExpressionNamedGroup() function can be used.
Example
; This expression matches a color setting string (with value red, green or blue) ; The colors are grouped with () and the color value is extracted in case of a match ; If CreateRegularExpression(0, "color=(red|green|blue)") If ExamineRegularExpression(0, "stype=bold, color=blue, margin=50") While NextRegularExpressionMatch(0) Debug "The color is " + RegularExpressionGroup(0, 1) Wend EndIf Else Debug RegularExpressionError() EndIf
See Also
ExamineRegularExpression(), NextRegularExpressionMatch(), RegularExpressionGroupPosition(), RegularExpressionGroupLength(), RegularExpressionNamedGroup()
Supported OS
All