0

I want to create a regular expression for a RegularExpressionValidator in Asp.net...

I want to create the following expression

(emailaddress ([,][SPACE]* emailaddress)* )?

emailaddress = \w+([-+.']\w+)@\w+([-.]\w+).\w+([-.]\w+)*

please check if emailaddress is correct, and how can I create the syntax for the above expression thank you

Victor
  • 1,108
  • 9
  • 29
  • 53
  • 1
    Here's a page with a regular expression email address validator: http://www.ex-parrot.com/pdw/Mail-RFC822-Address.html - email addresses are more complicated that you thought. – Tom Whittock Aug 21 '12 at 17:27

2 Answers2

1

Building on Using a regular expression to validate an email address,

ValidationExpression="(?:(?:^|,\s*)[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})\s*)+"
Community
  • 1
  • 1
Andrew Cheong
  • 29,362
  • 15
  • 90
  • 145
1

you can try with

ValidationExpression="^(([^<>()[\]\\.,;:\s@\""]+"

                        + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@"

                        + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"

                        + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+"

                        + @"[a-zA-Z]{2,}))$"

You can use this site in order to create your regex : RegexHero

Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51