Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regular Expression for EMail Validation

 
AT&T Communications
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Friends,
I need a regular expression for generalised email validation.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
- check the site naming policy
- use the search functionality
 
Max Habibi
town drunk
( and author)
Sheriff
Posts: 4118
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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,
M
 
Tom Blough
Ranch Hand
Posts: 263
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here's one I use:

 
Peter den Haan
author
Ranch Hand
Posts: 3252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

[^\\p{Cntrl}\\s()<>@,;:"\\[\\]]+@[-\\.\\w]+

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: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic