• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1645
  • Last Modified:

Solaris egrep Regex (Regular Expression) for a valid email address

Hello,

Does anyone have a good egrep Regex for what constitutes a valid email address?

I could do some basic checks, but I thought why not ask if someone already has one.  Perhaps certain characters aren't allowed and perhaps some unexpected ones are permitted - i don't know.

Thank You,
MJ
0
mj62mj62
Asked:
mj62mj62
2 Solutions
 
ahoffmannCommented:
http://examples.oreilly.com/regex/

be prepared for a huge and sophisticated regex ;-)
0
 
mj62mj62Author Commented:
Yikes - that may have been a bit more than I had in mind.  

I only need to sanity check it, maybe I'll stick with something relatively simple I write myself.

hmmm.....
0
 
ahoffmannCommented:
a simple one might be:

    [a-zA-Z0-9_.-]+@([a-zA-Z0-9-]+\.){1,}([a-z]){2,4}
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ozoCommented:
That misses fred&barney@stonehenge.com and other valid addresses
.+@.+\..+
would be safer
0
 
ahoffmannCommented:
/@_._
is invalid, I guess that you can find much more invalid examples for this really simple regex than for my whitelist aproach (which is not perfect, but see the very first suggestion and following comment:)
0
 
root_startCommented:
If you need some good stuff about Egrep Regular Expressions, just check this link: http://linuxreviews.org/beginner/tao_of_regular_expressions/
0
 
root_startCommented:
Ops... I forgot to send this link also, just for experts: http://www.ussg.iu.edu/UAU/advcomm/regexp.html
0
 
ahoffmannCommented:
hmm, I don't see how http:#16651655 answers (for someone unused to regex) the question: regex for valid email address.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now