ExamineRegularExpression()

语法

Result = ExamineRegularExpression(#RegularExpression, String$)
概要
Starts matching the #RegularExpression against the given String$. Individual matches can be iterated using the NextRegularExpressionMatch() function. From each match, the matching string, its position/length and any groups within the match can be extracted with the appropriate function.

参数

#RegularExpression The regular expression to use.
String$ The string to apply the regular expression on.

返回值

Returns non-zero if the matching was started successfully. Whether an actual match was found can be determined by calling NextRegularExpressionMatch().

示例

  ; This expression will match every word of 3 letter which begin by a lower case letter,
  ; followed with the character 'b' and which ends with an uppercase letter. ex: abC
  ; Each match is printed with its position in the original string.
  ;    
  If CreateRegularExpression(0, "[a-z]b[A-Z]")
    If ExamineRegularExpression(0, "abC ABc zbA abc")
      While NextRegularExpressionMatch(0)
        Debug "Match: " + RegularExpressionMatchString(0)
        Debug "    Position: " + Str(RegularExpressionMatchPosition(0))
        Debug "    Length: " + Str(RegularExpressionMatchLength(0))
      Wend
    EndIf
  Else
    Debug RegularExpressionError()
  EndIf

参阅

NextRegularExpressionMatch(), RegularExpressionMatchString(), RegularExpressionMatchPosition(), RegularExpressionMatchLength()

已支持操作系统

所有

<- CreateRegularExpression() - RegularExpression Index - ExtractRegularExpression() ->