RegularExpressionGroup()
语法
Result$ = RegularExpressionGroup(#RegularExpression, Group)概要
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.
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.
示例
; 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()
已支持操作系统
所有