#region 是否为ip
public static bool FoundMatch(string str)
{
try
{
return Regex.IsMatch(str, @"^(\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])$");
}
catch (ArgumentException ex)
{
return false;
}
}
#endregion
2014-7-11-C#正则-IP
最新推荐文章于 2025-07-29 11:21:14 发布