Email Address Validation

email me

This is a VBScript I wrote to determine the validity of an email address. Simple AI is about pattern recognition, and if you notice in the code below, a particular pattern is exactly what we’re looking for.

further reading link

The script

DIM strEmailAddress, objPatternMatch

strEmailAddress = "mrnettek@yahoo.com"

Set objPatternMatch = New RegExp

With objPatternMatch
.Pattern = "^[\w-\.]{1,}\@([\da-zA-Z-]{1,}\.){1,}[\da-zA-Z-]{2,4}$"
.IgnoreCase = False
.Global = False
End With
' The Test method objPatternMatch TRUE if a match is found or FALSE if a match is NOT found
If objPatternMatch.Test( strEmailAddress ) Then
msgbox strEmailAddress & " is a valid e-mail address"
Else
msgbox strEmailAddress & " is NOT a valid e-mail address"
End If

Set objPatternMatch = Nothing
Set strEmailAddress = Nothing

WScript.Quit(0)