IP address
using System;
using System.Text.RegularExpressions;
class RXassemblyApp {
static void Main(string[] args) {
string s = "123.45.67.89";
string e =
@"([01]?\d\d?|2[0-4]\d|25[0-5])\." +
@"([01]?\d\d?|2[0-4]\d|25[0-5])\." +
@"([01]?\d\d?|2[0-4]\d|25[0-5])\." +
@"([01]?\d\d?|2[0-4]\d|25[0-5])";
Match m = Regex.Match(s, e);
Console.WriteLine("IP Address: {0}", m);
for (int i = 1; i < m.Groups.Count; i++)
Console.WriteLine(
"\tGroup{0}={1}", i, m.Groups[i]);
}
}
Related examples in the same category