Result$ = RegularExpressionNamedGroup(#RegularExpression, GroupName$)Description
Extract the string matched by a named 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. GroupName$ The name of the group to extract. The group name is case sensitive.
Returns the string matched by the regular expression group.
Groups in a regular expression are defined by surrounding a sub-expression with braces "(" and ")". Groups can either accessed by index using functions like RegularExpressionGroup() or they can be assigned a name using the "(?<name>)" syntax as shown in the example below.
; This expression matches a color setting string (with value red, green or blue) ; The colors are grouped with () which has the name "col" assigned to it. ; This color name is then extracted ; If CreateRegularExpression(0, "color=(?<col>red|green|blue)") If ExamineRegularExpression(0, "stype=bold, color=blue, margin=50") While NextRegularExpressionMatch(0) Debug "The color is " + RegularExpressionNamedGroup(0, "col") Wend EndIf Else Debug RegularExpressionError() EndIf
ExamineRegularExpression(), NextRegularExpressionMatch(), RegularExpressionNamedGroupPosition(), RegularExpressionNamedGroupLength(), RegularExpressionGroup()