[AccessD] email validation

Gustav Brock Gustav at cactus.dk
Sat Jan 7 07:38:11 CST 2006


Hi Jim

Here's another pattern:

^(?:[\w\!\#\$\%\&'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&'\*\+\-\/\=\?
\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!\.)){0,61}[a-zA-Z0-9]? 
\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-](?!$)){0,61}[a-zA-Z0-9]?)|(?:\[(?:(?:[01]?\d{
1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$

which claims to have a proven record (browse to 2004-04-28, 7:48 pm):

http://www.codecomments.com/archive299-2004-4-184908.html 

However, it fails for me - and I don't have the need to debug it.

Note that addresses may have a subdomain like:

  submit.ry8JtxnVhqqmpAFS at spam.spamcop.net

/gustav


>>> martyconnelly at shaw.ca 07-01-2006 07:35 >>>
There is quite a range of vaild email addresses including the old X400 types
Mastering Regular Expressions.  Is the best Owl book for regexp

 The book ends with an example regular expression to match
an email address.  Its a 16,000+ byte regular expression.  Just shows
the scope of such a match when you want to get an email address "from
the wild".
This should verify or catch about 90-95% using regexp

 Function testEmail(strEmail As String) As Boolean

 If IsEmail(strEmail) Then
 ' email address ok
  Debug.Print "OK"
  testEmail = True
 Else
 ' email address not ok
  Debug.Print "False"

 End If
 End Function
 Function IsEmail(strText as String)
 'Need to Set reference to Microsoft VBScript Regular Expressions 5.5 
vbscript.dll/3
'or set for 5.6
 Dim regEx as Object
 Set regEx = New RegExp
 regEx.Pattern = "^[\w\-\._]+@[\w\-]{2,}(\.[\w\-]{2,})+$"
 'or               "^([\w-_]+\.)*[\w-_]+\@ ([\w-_]+\.)+[a-zA-Z]{2,3}$"
 regEx.ignoreCase = True
 regEx.Global = True
 IsEmail = regEx.Test(strText)
 End Function



Jim Moss wrote:

>Does anyone have a good email validation module that they would be willing to share?





More information about the AccessD mailing list