[AccessD] email validation

MartyConnelly martyconnelly at shaw.ca
Sat Jan 7 00:35:25 CST 2006


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?
>
>Thanks,
>
>Jim
>
>  
>

-- 
Marty Connelly
Victoria, B.C.
Canada






More information about the AccessD mailing list