ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Filter out bad email addresses (https://www.excelbanter.com/excel-programming/324366-filter-out-bad-email-addresses.html)

Chris W.

Filter out bad email addresses
 
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.

Tim Williams

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.





All times are GMT +1. The time now is 07:25 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com