ExamineRegularExpression()

Syntax

Result = ExamineRegularExpression(#RegularExpression, String$)
Description
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.

Parameters

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

Return value

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

Example

  ; 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

See Also

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

Supported OS

All

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