'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;
}
posted on 2004-06-02 18:52  维生素C.NET  阅读(1384)  评论(0)    收藏  举报