Regular expression to allow dashes in email

Please any one cam tell me how allow the follwing regular expression to allow the dashes(-) in email and also explain the regular expression  for email
I am very poor to understand regular expression for email
in my project it is say like this (this should be modified to allow dashes)
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"

Thanks in Advance
Latha
LathaLiquidHubAsked:
Who is Participating?
 
HonorGodConnect With a Mentor Software EngineerCommented:
So, the reason that the RegExp allows a dash (hyphen) is because of this part of the RegExp:

[-+.']

Which is the RegExp way of saying "pick exactly 1 of the listed characters"
0
 
HonorGodSoftware EngineerCommented:
Does this help?
\w+              = 1 or more "word" characters (letters, digits, or underscore)
([-+.']\w+)*     = 0 or more of
                     Exactly 1 of: a dash, plus, period, or single quote,
                     immediately followed by
                     1 or more "word" characters
@                = An at sign
\w+              = 1 or more "word" characters (letters, digits, or underscore)
([-.]\w+)*       = 0 or more of
                     Exactly 1 of: a dash, or period,
                     immediately followed by
                     1 or more "word" characters
\.               = A period
\w+              = 1 or more "word" characters (letters, digits, or underscore)
([-.]\w+)*       = 0 or more of
                     Exactly 1 of: a dash, or period,
                     immediately followed by
                     1 or more "word" characters

Open in new window

0
 
LathaLiquidHubAuthor Commented:
It great I understood very well

Thanks a Lot

Latha
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
LathaLiquidHubAuthor Commented:
/([\w-+\.]+)@((?:[\w-]+\.)+)([a-zA-Z]{2,4})/

Please Explain this also

Is this allow dashes(-) ?


Thanks
Latha
0
 
HonorGodSoftware EngineerCommented:
Depending upon the programming language being used, a RegExp can be within quotes, or delimited (started, and ended) with '/'




Thanks for the grade & points.

Good luck & have a great day.
/                 = Starting delimiter
([\w-+\.]+)       = Group #1 containing 1 or more instances of:
                    \w = a word character
                    -  = This "might" be a hyphen, depending upon the RegExp Engine
                         If you really want a dash/hyphen to be allowed, it is best
                         to either begin, or end the list of "characters" within a
                         class (i.e., within square brackets) with a dash/hyphen
                    +  = A plus sign
                    \. = a period
@                 = An at sign
(                 = Group #2, containing
  (?:[\w-]+\.)+)  = 1 or more instances of a non-capturing group containing
                    []+  = 1 or more of:
                      \w = Word characters
                      -  = minus sign/dash/hyphen
                    \.   = followed by a period
  (               = Begin Group #3 - the closing parenthesis is missing!
    [a-zA-Z]{2,4} = Exactly 2 to 4 upper, or lowercase letters
                  < I suspect that this is where the Group #3 closing parenthesis should go
)                 = End of Group #2
/                 = Ending delimiter

Open in new window

0
 
HonorGodSoftware EngineerCommented:
So to answer your question:

Q: Does it allow dashes?
A: Not in its current form, it is a syntactically invalid RegExp.

  If you were to correct the RegExp by adding a closing parenthesis in the specified place:

And put the dash in the first group at the beginning of the class, then dashes would be allowed before and after the @ sign, but not in the last 2-4 letters
/([-\w+\.]+)@((?:[\w-]+\.)+)([a-zA-Z]{2,4}))/

Open in new window

0
 
LathaLiquidHubAuthor Commented:
Thanks  A lot
Its great
Really a beatiful explanation

Latha
0
 
LathaLiquidHubAuthor Commented:
/([-\w+\.]+)@((?:[\w-]+\.)+)([a-zA-Z]{2,4}))/

No of parenthses are differing opening four and closing are 5 is this effects ?
0
 
HonorGodSoftware EngineerCommented:
Let's see:
/([-\w+\.]+)@((?:[\w-]+\.)+)([a-zA-Z]{2,4}))/ 
 |         | ||          | ||             ||
 +---------+ |+----------+ |+-------------+|
             +-------------+               |
                                           +--- Unmatched, I was wrong

Open in new window

0
 
LathaLiquidHubAuthor Commented:
Thank you
Can I remove the unmatched one and use the expression?

Latha
0
 
HonorGodSoftware EngineerCommented:
Yes, just remove it (i.e., the last one)
0
 
LathaLiquidHubAuthor Commented:
Hi HonorGod,

Could you please answer for question  
Id is  ID: 26971892

since one month i geting this error while deploying the WSP

Thanks in advance

Latha
0
 
HonorGodSoftware EngineerCommented:
I'm sorry. Latha, about what question are you talking / asking?  If the question is this one, restate it please.  If it is another question, please provide a link.

Thanks
0
 
LathaLiquidHubAuthor Commented:
0
 
HonorGodSoftware EngineerCommented:
Sorry, I'm unfamiliar with wsp.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.