The asp.net RegularExpressionValidator email regex does not validate all valid e-mailaddresses

In a project I’ve been working on I discovered that the Visual Studo built in regex for email that you get when you work with the RegularExpressionValidator doesn’t work for some email addresses that actually are valid. This goes for email addresses that has for example a hyphen (-) or a dot (.) directly in front of the @, i.e. emailme-@hotmail.com.

The built in regular expression looks like this:

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

There are a lot of resources on RegEx on the web so I wont walk it through, let’s just take a look at the problem described above and modify it instead of googling up a working one.

The second instance of \w+ means word boundary, 1 or more times. Change this + to a * to say 0 or more times instead. So now the complete regular expression looks like this:

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

Now all I want is a way to save this change in Visual Studio.

5 comments :

  1. Iv made the changes as you said....and it works just fine..........Keep it up......

    ReplyDelete
  2. Im no expert, but I believe you just made an excellent point. You certainly fully understand what youre speaking about, and I can truly get behind that. https://verifications.io

    ReplyDelete
  3. It was wondering if I could use this write-up on my other website, I will link it back to your website though.Great Thanks. hotmail.com

    ReplyDelete
  4. Buy Gmail PVA Accounts from our company because we have the best experts in the markeet who create accounts with different USA Ips Buy Bulk Gmail Accounts

    ReplyDelete
  5. Contest is furious among real estate professionals, so this is your method of getting the leap on the opposition and situating your image for progress. GMX Mail How to Create an Account

    ReplyDelete