using System.Collections.Generic;
using System.Text.RegularExpressions;
public static void Main()
var IpRegEx = @"^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$";
var ipList = new List<string>();
ipList.Add("355.168.0.1");
ipList.Add("192.168.0.1");
ipList.Add("192.300.300.300");
ipList.Add("10.28.38.8");
ipList.Add("255.255.255.0");
ipList.Add("255.256.0.0");
ipList.Add("355.168.0.1");
ipList.Add("0.254.255.0");
foreach (var curIp in ipList)
var match = Regex.Match(curIp, IpRegEx);
Console.WriteLine("{0}\tMatches (Considered Valid)", match.Value);
Console.WriteLine("{0}\tDoes not match. (Considered Invalid)", curIp);