public static bool IsIPAddress(string str)
{
if (string.IsNullOrWhiteSpace(str) || str.Length < 7 || str.Length > 15)
return false;
string regformat = @"^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})";
Regex regex = new Regex(regformat, RegexOptions.IgnoreCase);
return regex.IsMatch(str);
}