I have a textbox and the only input that it should take is either a single ip address or a range in the form of: 10.2.3.4-10
I have this so far:
string txt = "10.13.11.12-100";
string re1 = "((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))(?![\\d])"; // IPv4 IP Address 1
string re2 = ".*?"; // Non-greedy match on filler
string re3 = @"\b([0-9]{1,2}|1[0-9]{2}|2[0-4][0-9]|25[0-5])\b";//"([0-255])"; // Integer Number 1
Regex r = new Regex(re1 + re2 + re3, RegexOptions.IgnoreCase | RegexOptions.Singleline);
Regex r2 = new Regex(re1, RegexOptions.IgnoreCase | RegexOptions.Singleline);
Match m = r.Match(txt);
Match m3 = r2.Match(txt);
if (m.Success || m3.Success)
{...}
Only thing is with that, if I have 100.100.11.11-256
it will still return true since it matches m3.Success
above as true.
How to fix that?