Verifying email address format

  • Thread starter Thread starter Brown
  • Start date Start date
B

Brown

I developed an app (Access 2003) for a customer. Going through the QC
process they decided the field that calls for an email address needed to be
formatted so that it had to at least have the proper format to be an email
address. To make it more interesting, the Government addresses may have
two, three or four levels to the right of the @. I told him it couldn't be
done without a lot of effort & time (read money). Did I lie?

Brown
 
Brown said:
I developed an app (Access 2003) for a customer. Going through the QC
process they decided the field that calls for an email address needed
to be formatted so that it had to at least have the proper format to
be an email address. To make it more interesting, the Government
addresses may have two, three or four levels to the right of the @.
I told him it couldn't be done without a lot of effort & time (read
money). Did I lie?

Brown

You can weed out a lot of invalid addresses with this function:

'----- start of code -----
Function IsValidEmailAddress(Candidate As String) As Boolean

If Trim(Candidate) Like "?*@[!.]*.[!.]*" Then
If Not Candidate Like "*@*@*" Then
IsValidEmailAddress = True
End If
End If

End Function
'----- end of code -----

That will allow multilevel domains, but it won't catch all invalid
addresses. I'll bet you could build a regular expression that would
catch every address that is syntactically invalid, but that's more
complicated and I've never had occasion to try.
 
Depends on your definition of "lied".

If you were to use Regular Expressions, it's quite easy. The difficult part
is to come up with the appropriate pattern to match for. One possible
pattern is "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$" That particular pattern allows
any number of letters (no numbers) before the @ character, followed by up to
three levels to the right of the @ character. I'm afraid I'm not an expert
in Regular Expression patterns, but a Google search will have literally
thousands of hits.

http://www.mvps.org/access/modules/mdl0063.htm at "The Access Web" is an
example of how to use Regular Expressions in Access.
 
Depends on your definition of "lied".

If you were to use Regular Expressions, it's quite easy. The difficult part
is to come up with the appropriate pattern to match for. One possible
pattern is "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$" That particular pattern allows
any number of letters (no numbers) before the @ character, followed by up to
three levels to the right of the @ character.

Good suggestion - but not flawless.

One of my (no longer active) email addresses was
(e-mail address removed); another I use resembles

(e-mail address removed)

Even with regular expressions this is tough, since email addresses are
VERY irregular!

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
John Vinson said:
Depends on your definition of "lied".

If you were to use Regular Expressions, it's quite easy. The difficult part
is to come up with the appropriate pattern to match for. One possible
pattern is "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$" That particular pattern allows
any number of letters (no numbers) before the @ character, followed by up to
three levels to the right of the @ character.

Good suggestion - but not flawless.

One of my (no longer active) email addresses was
(e-mail address removed); another I use resembles

(e-mail address removed)

Even with regular expressions this is tough, since email addresses are
VERY irregular!

I knew full-well that the Regular Expression pattern I suggested was flawed,
but it was the first one I found. There's a site devoted to sharing RexEx
patterns, but I couldn't remember its URL. It's http://www.regexlib.com

Actually, I don't think it should be that tough to get a working RegEx
pattern. I think the rules are fairly strictly as to what characters are
valid. While it's true that email addresses are irregular, you don't really
care what's before the @, as long as it's valid characters (some special
characters such as _ are valid, but I don't have the complete list). I'm
assuming that there's an appropriate standard out there somewhere for what's
a valid email address, in which case it's likely defined in terms of a
pattern. Doing a search on email at RegExLib.com turned up several good
candidates.

BTW, what's contradancing?
 
BTW, what's contradancing?

Lots of fun, for one thing!

http://www.sbcds.org/contradance/whatis/

for all you would ever want to know about it (all, that is, which can
be transmitted in a digital medium; the only way to really know about
it is to DO it!)

I've been dancing, off and on, since college; my wife and I are former
co-presidents of the Boise Contradance Society, and occasionally call
dances. I wish I could play an instrument (hammer dulcimer maybe) in
the band but the five folks in ContraBand are REALLY good professional
musicians and I'd never catch up!

John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Thanks for the info folks,
I think I have satisfied my customer.

Brown

Douglas J. Steele said:
John Vinson said:
Depends on your definition of "lied".

If you were to use Regular Expressions, it's quite easy. The difficult part
is to come up with the appropriate pattern to match for. One possible
pattern is "^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$" That particular pattern allows
any number of letters (no numbers) before the @ character, followed by
up to
three levels to the right of the @ character.

Good suggestion - but not flawless.

One of my (no longer active) email addresses was
(e-mail address removed); another I use resembles

(e-mail address removed)

Even with regular expressions this is tough, since email addresses are
VERY irregular!

I knew full-well that the Regular Expression pattern I suggested was
flawed,
but it was the first one I found. There's a site devoted to sharing RexEx
patterns, but I couldn't remember its URL. It's http://www.regexlib.com

Actually, I don't think it should be that tough to get a working RegEx
pattern. I think the rules are fairly strictly as to what characters are
valid. While it's true that email addresses are irregular, you don't
really
care what's before the @, as long as it's valid characters (some special
characters such as _ are valid, but I don't have the complete list). I'm
assuming that there's an appropriate standard out there somewhere for
what's
a valid email address, in which case it's likely defined in terms of a
pattern. Doing a search on email at RegExLib.com turned up several good
candidates.

BTW, what's contradancing?
 
Back
Top