Demonstration script that uses VBScript’s RegExp object to match the contents of a string variable against a regular expression. Set the strStringToMatch variable to the string you wish to test and set the strRegExp variable to the regular expression you wish to test it against.

Visual Basic
Edit|Remove
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objShell = CreateObject("WScript.Shell")

strRegExp = ".{1,}@.{1,}\..{2,3}"
strStringToMatch = "scripter@microsoft.com"


Set objRE = New RegExp
objRE.Global     = False
objRE.IgnoreCase = True
objRE.Pattern    = strRegExp

If objRE.Test(strStringToMatch)=True Then
   WScript.Echo "String Matches Regular Expression"
Else
   WScript.Echo "String Doesn't Match Regular Expression"
End If