0

Below regex is not allowing email id with underscore like myName_6@a.com

@"^([0-9a-zA-Z]([-.w]*[0-9a-zA-Z_])*@([0-9a-zA-Z][-w]*[0-9a-zA-Z].)+[a-zA-Z]{2,9})$"

any idea?

stema
  • 90,351
  • 20
  • 107
  • 135
Joe
  • 47
  • 1
  • 6
  • `0-9a-zA-Z` does indeed not allow an underscore – Emond Mar 14 '13 at 07:44
  • yes, want to allow underscore in it – Joe Mar 14 '13 at 07:44
  • ' "^([0-9a-zA-Z]([-.w]*[0-9a-zA-Z_])*@([0-9a-zA-Z][-w]*[0-9a-zA-Z].)+[a-zA-Z]{2,9})$" ' – Joe Mar 14 '13 at 07:46
  • possible duplicate of [Regular Expression for alphanumeric and underscores](http://stackoverflow.com/questions/336210/regular-expression-for-alphanumeric-and-underscores) – Emond Mar 14 '13 at 07:47
  • `@"^([0-9a-zA-Z_]+@([0-9a-zA-Z][-w][0-9a-zA-Z].)+[a-zA-Z]{2,9})$"` – Bart Mar 14 '13 at 07:49
  • possible duplicate of [Using a regular expression to validate an email address](http://stackoverflow.com/questions/201323/using-a-regular-expression-to-validate-an-email-address) – stema Mar 14 '13 at 07:51

2 Answers2

0

There's no underscore anywhere in the regexp, which accounts for it not matching underscores. Try adding an underscore to the list of allowed characters to the left of the @-sign.

Jenny D
  • 1,225
  • 9
  • 20
  • 1
    Could have just linked to [this](http://stackoverflow.com/questions/336210/regular-expression-for-alphanumeric-and-underscores) – ThaMe90 Mar 14 '13 at 07:46
0

try this

 /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/