Mega Code Archive

 
Categories / C# / Network
 

Is Ip Address By Regular Expression

using System.Text.RegularExpressions; public static class Validate {     public static bool IsIpAddress(string value)     {         if (string.IsNullOrEmpty(value))             return false;         Regex ipAddress = new Regex(@"^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$", RegexOptions.Compiled | RegexOptions.IgnoreCase);         return ipAddress.IsMatch(value);     } }