Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Test valid email adresses
Message
From
09/05/2014 03:08:40
 
 
To
06/05/2014 16:21:19
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows NT
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01599639
Message ID:
01599769
Views:
62
>How do I test to see if email adresses in a table are valid?
>
>what would you recommend as a good regular expression?

This function uses the official regular expression to validate the email address.
Function ValidEmail
Lparameters tcMail
Local lcPattern As String, ;
llReturn As Boolean, ;
loRegex As Object
If Pcount() > 0 And Vartype(m.tcMail) = [C]
Text To m.lcPattern Noshow Pretext 15
(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*
| "(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]
| \\[\x01-\x09\x0b\x0c\x0e-\x7f])*")
@ (?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
| \[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}
(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:
(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]
| \\[\x01-\x09\x0b\x0c\x0e-\x7f])+)
\])
Endtext
m.lcPattern = Strtran(m.lcPattern, [ ], [])
m.loRegex = Createobject([VBScript.RegExp])
m.loRegex.Pattern = m.lcPattern
m.loRegex.IgnoreCase = .T.
m.loRegex.Global = .F.
m.llReturn = m.loRegex.Test(m.tcMail)
m.loRegex = .Null.
Release m.loRegex
Endif
Return m.llReturn

Previous
Reply
Map
View

Click here to load this message in the networking platform