• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Regular Expression for EMail Validation

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Friends,
I need a regular expression for generalised email validation.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
- check the site naming policy
- use the search functionality
 
town drunk
( and author)
Posts: 4118
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 263
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's one I use:

 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic