指定された文字列が正規表現パターンと一致するかどうかを確認します。Testメソッドは、ブール値(TrueまたはFalse)を戻します。文字列がパターンと一致する場合はTrueを戻し、一致しない場合はFalseを戻します。
構文: RegExpObject.Test(string)
引数: - string: 正規表現パターンに対してテストする文字列。
例:
Dim regEx, str, result
' Create a new RegExp object
Set regEx = CreateObject("VBScript.RegExp")
' Set the pattern for matching email addresses
regEx.IgnoreCase = True
regEx.Global = True
regEx.Pattern = "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"
' Test if the string is a valid email
str = "example@example.com"
result = regEx.Test(str)
If result Then
'Logic for Valid email
Else
'Logic for Invalid email
End If