I'm using the following regex to validate an email address text box in javascript:-
var regex = /^[\_]*([a-z0-9]+(\.|\_*)?)+@([a-z][a-z0-9\-]+(\.|\-*\.))+[a-z]{2,6}$/i;
I need to also run it in the back end of the asp.NET(4) VB site to prevent injection.
When I convert it to what I think it should be for .NET and run it in http://myregextester.com/ set to use .NET and VB it passes:-
^[_]*([a-z0-9]+(.|_*)?)+@([a-z][a-z0-9\-]+(.|-*.))+[a-z]{2,6}$
However when I put it in my code it doesn't work:-
If (Not Regex.IsMatch(theEmail, "^[_]*([a-z0-9]+(.|_*)?)+@([a-z][a-z0-9\-]+(.|-*.))+[a-z]{2,6}$")) Then
Return False
Else
Return True
End If
Any help with the conversion to VB would be appreciated.