Unable to validate e-mail format
- by Aishwarya Shiva Pareek
I am using this code which was suggested by my friend to validate an email id format in C#.
public bool IsValidEmail(string strIn)
{
string strPattern = "^([0-9a-zA-Z]([-.\\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\\w]*[0-9a-zA-Z]\\.)+[a-zA-Z]{2,9})$";
if (System.Text.RegularExpressions.Regex.IsMatch(strIn, strPattern))
{ return true; }
return false;
}
When I pass the value of the strIn as
[email protected]
This function returns false. Please tell me whats wrong with it?