验证ip地址
/// <summary>
/// 验证ip地址
/// </summary>
/// <param name="ipAddress"></param>
/// <returns></returns>
public static bool ValidateIPAddress(string ipAddress)
{
//https://blog.csdn.net/linxinfa/article/details/99306256
Regex validipregex = new Regex(@"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$");
return (ipAddress != "" && validipregex.IsMatch(ipAddress.Trim())) ? true : false;
}
本文来自博客园,作者:.net&new,转载请注明原文链接:https://www.cnblogs.com/wugh8726254/p/16523451.html