'check the Email if is valid (using regular expression).
private bool CheckEmail(string EmailAddress)
{
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(EmailAddress, strPattern) )
{ return true; }
return false;
}
'By the way , tip a function to check IP
static bool IsValidIP(string ip) {
string[] parts = ip.Split('.');
if (parts.Length != 4) return false;
try {
if (Byte.Parse(parts[0]) == 0x00)
return false;
foreach (string part in parts)
if (Byte.Parse(part) > 0xFF)
return false;
}
catch(Exception) { return false; }
return true;
}
Email address format validate function by C#
最新推荐文章于 2021-03-21 02:28:34 发布