comp • gb.pcre • regexp • match

RegExp.Match (gb.pcre)

Static Function Match ( Subject As String, Pattern As String [ , CompileOptions As Integer, ExecOptions As Integer ] ) As Boolean

Since 3.5

This static method takes the same parameters as the Regexp constructor does. However, is doesn't create a new object but instead it returns whether the subject matches the pattern.

It is handy for one-line string matching where the LIKE keyword is not sophisticated enough:


Use "gb.pcre"

If RegExp.Match("Zebra1", "[a-zA-Z]*") Then
    Print "Match"
    Print "No Match!"
  ' This checks whether the text in a TextBox contains at least four identical
  ' characters in a row.
  If Regexp.Match(TextBox1.Text, "([a-zA-z])\\1{3,}") Then
    Error "I don't think this is a word."

Effectively, Regexp.Match() is a (slightly more efficient) short-hand for

Dim hTemp As New RegExp(sSubject, sPattern, iCompileOptions, iExecOptions)

Return hTemp.Offset <> -1