Jump to content
Clubplanet Nightlife Community

AAAAHHHH!!! email addresses are a programmer's nightmare


Recommended Posts

from RFC 2486 ...

a valid Network Address Identifier (email address) is:

username = dot-string

realm = realm "." label

label = let-dig * (ldh-str)

ldh-str = *( Alpha / Digit / "-" ) let-dig

dot-string = string / ( dot-string "." string )

string = char / ( string char )

char = c / ( "\" x )

let-dig = Alpha / Digit

Alpha = %x41-5A / %x61-7A ; A-Z / a-z

Digit = %x30-39 ;0-9

c = < any one of the 128 ASCII characters, but not any special or SP

x = %x00-7F

; all 127 ASCII characters, no exception

SP = %x20

; Space character

special = "<" / ">" / "(" / ")" / "[" / "]" / "\" / "."

/ "," / ";" / ":" / "@" / %x22 / Ctl

Ctl = %x00-1F / %x7F

; the control characters

; (ASCII codes 0 through 31 inclusive and 127)

Link to comment
Share on other sites

if you are using perl, you can try this regular expression:

(taken from rootworks.com/rx - where i learned regexp 5 years ago)

if ($c =~ /^([a-zA-Z\-_]+)@(([a-zA-Z\-_]+)\.)+([a-zA-Z]+)$/)

{

print "YES! - probably an email address\n";

print "user was $1\n";

print "domain was $2\n";

print "TLD was $3\n";

}

else

{

print "definitely NOT an email address, loser\n";

}

Link to comment
Share on other sites

well, here's my hack in coldfusion:

<cfif NOT refindnocase("^(([0-9A-Za-z_\-]+\.)*)(([0-9A-Za-z_\-])+)(@)(([0-9A-Za-z_\-]+\.)+)([0-9A-Za-z_\-]{2,})$",attributes.email)>

<cfset valid = 0>

<cfset user_error = listappend(user_error,"Email address is not properly formatted.","|")>

</cfif>

basically it'll accept things like:

are.you.receiving.me@domain.co.uk

me@domain.com

you@minnesota.museum [yes it is a TLD - i was surprised too!]

hi_there-mr.crazy@person.com

obviously it would be nice to accept the IP-address variant too.

is it:

blah@[0.0.0.0]

or...

bleck@0.0.0.0

?

why coldfusion? because i'm a sadomasochist.

and it also happens to be my workplace standard. mer.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...