/// <summary> /// 验证字符串是否IP合法 /// </summary> /// <returns>是IP返回true 负责返回false</returns> private bool IsIP(string ip) { if (cmbIP.Text.Trim() == ".") { return true; } else { return Regex.IsMatch(ip.Trim(), @"^((2[0-4]d|25[0-5]|[01]?dd?).){3}(2[0-4]d|25[0-5]|[01]?dd?)$"); } }