File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Regular Expression for EMail Validation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regular Expression for EMail Validation" Watch "Regular Expression for EMail Validation" New topic

Regular Expression for EMail Validation

AT&T Communications

Joined: Jun 08, 2004
Posts: 1
Hello Friends,
I need a regular expression for generalised email validation.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
- check the site naming policy
- use the search functionality

Max Habibi
town drunk
( and author)

Joined: Jun 27, 2002
Posts: 4118
Hi "AT&T",

The 'Ranch doesn't really have a lot of rules, but we do request that our members adhere to reasonable, non-fictional looking names. We've just found that it tends for a nicer community.

To answer your question, I'll need some information. For example, how far do you need this email validation to go? On the one end of the spectrum, there's just checking to see if it contains an @ symbol. On the other, you could do email IP checking.

Just sorts talk about your problem, and we'll see if we can help.

all best,

Java Regular Expressions
Tom Blough
Ranch Hand

Joined: Jul 31, 2003
Posts: 263
Here's one I use:

Tom Blough<br /> <blockquote><font size="1" face="Verdana, Arial">quote:</font><hr>Cum catapultae proscriptae erunt tum soli proscripti catapultas habebunt.<hr></blockquote>
Peter den Haan
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Looks too tight. If you check out the RFC you'll be surprised to see what characters are legal in an email address. We ended up using


But I'd be the first to admit that this is actually too lax - although it should allow any valid e-mail address it will also allow some invalid ones, especially in the domain name part.

- Peter
I agree. Here's the link:
subject: Regular Expression for EMail Validation
It's not a secret anymore!