Result$ = RegularExpressionGroup(#RegularExpression, Group)Description
Extract the string matched by a group within the regular expression after a call to NextRegularExpressionMatch().
#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.
Returns the string matched by the regular expression group.
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.
; 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
ExamineRegularExpression(), NextRegularExpressionMatch(), RegularExpressionGroupPosition(), RegularExpressionGroupLength(), RegularExpressionNamedGroup()