• 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
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

Jakarta RegExp - Email Validation

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am looking for email validation regular expression using org.apache.regexp.RE?

Also, where can I find document describing email address specification?


Thanks.

SK
 
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it's not entirely clear from your question what you want to do, but i'm assuming you're talking about e-mail addresses. trying to validate entire e-mail messages with a regular expression wouldn't make much sense, after all.

these days, Internet (SMTP) e-mail addresses are defined in RFC 2822, and you want to look in section 3.4. be aware that the actual syntax is a lot more complex and flexible than it seems at first glance. be aware, also, that not every piece of e-mail sending software in the world is all that strict about what types of things they call an "address", so you may encounter forms that do not fit the definition, and you'll have to try and cope with them.
 
SAM KUMAR
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your reply.

Please eloborate why it does not make sense to use reg exp?
"....trying to validate entire e-mail messages with a regular expression wouldn't make much sense, after all."


I am trying to add reg exp which should allow quoted user, for "firstname lastname"@host.com. This is what I have:
RE emailPattern = new RE("((^[a-zA-Z][\\w\\.-]*[a-zA-Z0-9])|([^\"*$\"]))@[a-z-Z0-9][\\w\\.-]*[a-zA-Z0-9]\\.[a-zA-Z][a-zA-Z\\.]*[a-zA-Z]$");

Thanks.

SK
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
less than a month ago, we had a small discussion here:

https://coderanch.com/t/376344/java/java/Regex-email-verifying

- not discussing the RFC
- using javas regexes - I don't know where they differ from jakartas.
 
SAM KUMAR
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi:

Thanks for your reply. That was very helpful.

Now I am trying to prevent continous dot's, for ex: [email protected]. Please let me know how do i prevent this using RE.

Beck, please eloborate why it does not make sense to use reg exp? Is there any performance issue?

"....trying to validate entire e-mail messages with a regular expression wouldn't make much sense, after all."


Thanks.

SK
 
M Beck
Ranch Hand
Posts: 323
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm sorry, i wasn't making myself very clear -- i meant it would not make sense to use regexes to validate an entire e-mail message, as opposed to just the address. my apologies.
 
Ranch Hand
Posts: 884
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even if you use regular express to validate that the email address is in proper format, you cannot be sure that it is a valid, working, live email address.

The user could always enter addresses such as [email protected].
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic