View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tim Williams Tim Williams is offline
external usenet poster
 
Posts: 1,588
Default Filter out bad email addresses

Not sure about the exact regular expression here but something like
this should work.

Tim.


Function EmailOK(sIn As String) As Boolean

Static regEx As Object

bValid = False
If regEx Is Nothing Then
Set regEx = CreateObject("vbscript.regexp")
regEx.Pattern =
"^[A-Z][\w\.-]*[A-Z0-9]@[A-Z0-9][\w\.-]*[A-Z0-9]\.[A-Z][A-Z\.]*[A-Z]$"
regEx.Global = True
regEx.IgnoreCase = True
End If

EmailOK = regEx.test(sIn)

End Function




"Chris W." wrote in message
...
Does anyone have existing code that filters out bad email
addresses. I can write my own routine, but i need to know
what characters are not allowed on the Left and right of
the @ sign.