AilisidanShow.Helper.GetIpHelper.IsIPAddress C# (CSharp) Method

IsIPAddress() public static method

public static IsIPAddress ( string str ) : bool
str string
return bool
        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);
        }