RegularExpressionNamedGroup()
语法
Result$ = RegularExpressionNamedGroup(#RegularExpression, GroupName$)概要
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.
Remarks
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()
已支持操作系统
所有