473,382 Members | 1,273 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Reg Expression - valid International email addresses?

Can anyone please help me with a regular expression
to test for Valid International Email Addresses?
Also, which version of javascript (1.2 ?) is needed for same?

Thanks.
Regards.
Jul 20 '05 #1
14 8287
nagual wrote:
Can anyone please help me with a regular expression
to test for Valid International Email Addresses?


Yes, I know this says "Perl", not "JavaScript" but read it anyway. OK?

http://www.perldoc.com/perl5.8.0/pod...-mail-address-

--
David Dorward http://david.us-lot.org/
Redesign in progress: http://stone.thecoreworlds.net/
Microsoft announces IE is dead (so upgrade):
http://minutillo.com/steve/weblog/20...ces-ie-is-dead
Jul 20 '05 #2
The following uses regular expressions adapted from Jeffery Friedl's
book to check the format of an email string.

rxEmail =
/^\w[-.\w]*\@[-a-b0-9]+(?:\.[-a-b0-9]+)*\.(?:com|edu|biz|org|gov|int|inf
o|mil|net|name|museum|coop|aero|[a-z][a-z])\b/;

Convert to lower case before testing.

rxEmail.test(email.toLowerCase());

Note that the pattern used non-capture parenthesis which are available
in IE5.5+ and JavaScript 1.5. For older browsers like NN4 replace (?: by
( in the above expression.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
On 12 Jul 2003 16:27:45 GMT, Mark Szlazak <an*******@devdex.com>
wrote:
The following uses regular expressions adapted from Jeffery Friedl's
book to check the format of an email string.

rxEmail =
/^\w[-.\w]*\@[-a-b0-9]+(?:\.[-a-b0-9]+)*\.(?:com|edu|biz|org|gov|int|inf
o|mil|net|name|museum|coop|aero|[a-z][a-z])\b/;

Convert to lower case before testing.

rxEmail.test(email.toLowerCase());

Note that the pattern used non-capture parenthesis which are available
in IE5.5+ and JavaScript 1.5. For older browsers like NN4 replace (?: by
( in the above expression.


My email address has a + in it, you don't seem to list that one
above...

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #4
Well, then just put the + in.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5
Mark Szlazak wrote on 12 jul 2003 in comp.lang.javascript:
Forgot one thing. If you only want international emails then modify the
regex to:

rxEmail =/^\w[-.\w]*\@[-a-b0-9]+(?:\.[-a-b0-9]+)*\.[a-z][a-z]\b/;


..int

as in:

http://www.who.int/

is THE international domain postfix.
..uk, .nl, .ca, etc are the NATIONAL ones
--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 20 '05 #6
On 13 Jul 2003 04:37:37 GMT, Mark Szlazak <an*******@devdex.com>
wrote:
Well, then just put the + in.


and all the thousands of other legal characters... that's the problem
you're missing. I wouldn't bother with the validation at all... as
all you'll do is get a junk valid-looking email address, rather than
simply an incorrect one.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #7
If your seeking perfection and want to get all those "thousands" of
emails then speak to God.
I'm sticking with pragmatic solutions.

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #8
On 13 Jul 2003 14:57:45 GMT, Mark Szlazak <an*******@devdex.com>
wrote:
If your seeking perfection and want to get all those "thousands" of
emails then speak to God.
I'm sticking with pragmatic solutions.


Because of the + in my email address being rejected, I've not done
over 3000 UKP worth of online business with various online agencies
this year (mostly computer equipment and travel.) now you may be
happy to throw away that business, after all I'm just one bloke right?
but are your clients fully aware?

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #9
JRS: In article <3f*********************@news.frii.net>, seen in
news:comp.lang.javascript, Mark Szlazak <ms******@aol.com> posted at
Sat, 12 Jul 2003 21:07:39 :-
Forgot one thing. If you only want international emails then modify the
regex to:

rxEmail =/^\w[-.\w]*\@[-a-b0-9]+(?:\.[-a-b0-9]+)*\.[a-z][a-z]\b/;


International does not mean foreign; it includes America. Indeed, the
OP seems to be Australian. Some US E-mail addresses end, I believe, in
..us, as is right and proper. Many non-US ones end in .com or .net, too.

The existence of a national indication in most cases implies a
significant connection with that country, with certain well-known
exceptions; the converse is not true.

Don't believe all that you read in books; even if it was good when
written, which is uncertain, the facts might have changed.

There is little point in doing much validation on an E-address.

It is *impossible* to tell, other than by hearing of delivery, that an
E-address is deliverable to; I can change the rules at this site while
not connected to the Net. Attempted exact validation risks false
negatives (so it needs to be possible to send to an address that the
test actually rejects) and false over-confidence.

ISTM that the only reasonable validation is one checking that the field
is non-empty and that its contents match the minimum requirements; that
will deal with cases where some other piece of information is entered.

/.+@/+\..+/ seems about as strong a test as is appropriate; if I have
it right, check for something @ something . something .

E-address validation must be a FAQ candidate; it could provide a basis
for an entry on RegExps.

--
John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> JS maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/JS/&c., FAQ topics, links.
Jul 20 '05 #10
The pattern with + is just one. I'm still waiting on those thousands.
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #11
Mark Szlazak wrote:
The pattern with + is just one. I'm still waiting on those thousands.

I think the idea is to build an array of every singly possible valid email
address. How long is an email address aloud to be? 255 characters for the
name part?, then 255 characters for the domain name part?...

so, all you need to do is build an array with
4.653138834498368145776998455562e+613 elements, then check if the inputted
email address is in taht array.
Simple.

Jul 20 '05 #12
On 14 Jul 2003 01:17:35 GMT, Mark Szlazak <an*******@devdex.com>
wrote:
The pattern with + is just one. I'm still waiting on those thousands.


You've already been given the link to the perl faq which contains a
RegExp many hundreds of chars long which is still not enough.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #13
On 14 Jul 2003 01:17:35 GMT, Mark Szlazak <an*******@devdex.com>
wrote:
The pattern with + is just one. I'm still waiting on those thousands.


Underscore (_) for starters. 1999 more to go.

The point is that even with a perfect regular expression, you don't
have any idea whether the address is valid or not. It is impossible
to determine unless you send mail to the account and get a response
from the person. By attempting to validate the email address, all you
do is risk disallowing valid addresses. If you're going to do any
validation at all just check whether there is a @ and a subsequent .
character.

Whenever I sign up for something and I don't really want mail I always
use my old ISP's "bitbucket" address because the incoming mail goes
directly into the NUL device. It's very efficient.

Regards,
Steve
Jul 20 '05 #14
Two of my responses haven't posted over the last two days so I'll post
again and address Jim, John and Steve.

Jim now points to Tom's large regex and says that's still not enough.
Well it actually could be too much for someone else since patterns
may never occur in the wild! People may just be interested in whats
out there and if a simple regex email format validator good enough!

John talks about this when he mentions a topic related to reliability.
If a simple format checker is 99.99 percent reliable then what is the
significance of those false negatives? It maybe none. He also provides
a simple overall pattern but the OP may needs something more specific
to filter international emails ... whatever that means.

Steve then talks about two issues that are related but seperate. There
is the issue of a valid general email format and then the issue of
whether a specific instant of it exists.

I would be interested in some empirical data on what's out there and
how that has changed over time versus what's possible via specs.

Thanks.
Jul 20 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Hoang | last post by:
anyone know of an algorithm to filter out real email addresses as opposed to computer generated email addresses? I have been going through past email archives in order to find friends email...
9
by: Holden Caulfield | last post by:
Hello! Does anyone know a good archive for all different types of Regular expressions? I am 90% done a website and the last 10% is putting validation on over 100 fields. They range from...
2
by: Bryce Budd | last post by:
Hi all, I am trying to use a regular expression validator to check for the existence of PO Box in an address textbox. The business rule is "No addresses with PO Boxes are allowed." What I...
0
by: Conference Secretary | last post by:
CALL FOR PAPERS International Conference on Intelligent Agents, Web Technologies and Internet Commerce http://www.ise.canberra.edu.au/conferences/iawtic05/ Jointly with International...
12
by: laurenq uantrell | last post by:
Is there an easy way to loop through all rows and remove all international alphabet characters from a column in a table, for example remove German umlauts "" and convert them to a simple "u"....
0
by: avinash | last post by:
International Conference on Computational Intelligence and Multimedia Applications, August 16-18, 2005 University of Nevada, Las Vegas, USA (www.iccima.org) F I R S T C A L L F O R P...
6
by: JohnSouth | last post by:
Hi I've been using a Regular expression to test for valid email addresses. It looks like: \w+(\w+)*@\w+(\w+)*\.\w+(\w+)* I've now had 2 occassions where it has rejected and email address...
2
by: Ramesh | last post by:
I have a reguar expression syntax that works fine when used in a RegularExpressionValidation control. If I use the exact same regular expression using System.Text.RegularExpressions.Regex to...
12
by: ll | last post by:
I am trying to finalize a regular expression in javascript to only allow emails with a certain domain to be valid. Here is what I have so far: var emailFilter2=/\@aol.com/;...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.