I'm trying to check if the string I'm getting from a web form is acceptable but it isn't working at all. I'm using these regular expressions on javascript without any visible problem.
Javascript version:
Code:
var emailFilter1=/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/;
var emailFilter2=/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/;
var generalFilter=/^[a-zA-Z].[a-zA-Z0-9\-\._ ]+$/
var generalFilter2=/^[a-zA-Z0-9\-\._ ]+$/
generalFilter.test(user.value)
C# version:
Code:
Regex filter1 = new Regex(@"/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/");
Regex filter2 = new Regex(@"/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/");
Regex generalFilter = new Regex(@"/^[a-zA-Z].[a-zA-Z0-9\-\._ ]+$/");
Regex generalFilter2 = new Regex(@"/^[a-zA-Z0-9\-\._ ]+$/");
bool isTrue = generalFilter.IsMatch(user.Text);
isTrue is always set at false. I'm stuck on this for hours now. Any help is welcome. :)