This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: Regular Expression for EMail Validation
Similar Threads
How can I add error handling facilities to this code?
Jakarta RegExp - Email Validation
Email id validation - how this code works?
Please share any Java code to do email validation
Date Format Issue