public class CheckIp
{
public bool IsCorrenctIP(string ip)
{
string pattrn = @"(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])";
if (System.Text.RegularExpressions.Regex.IsMatch(ip, pattrn))
{
return true;
}
else
{
return false;
}
}
}
转载于:https://blog.51cto.com/weixiuting/955997