using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"10\.(?:[0-9]|[0-1][0-9]?|20)\.0\.(?:25[0-4]|2[0-4][0-9]|1[0-9][0-9]|[2-9][0-9]|1[1-9]|[1-9])";
string input = @"10.0.0.1
10.19.0.13
10.22.0.13
10.20.0.2
10.0.0.6
10.24.0.1
10.19.0.233
10.18.0.13
10.17.0.12
10.0.0.12
10.0.0.211
10.3.0.123
10.4.0.121
10.5.0.200
10.5.0.201
10.5.0.1
10.4.0.0
10.4.0.254
10.0.0.12
10.9.0.134
10.10.0.112
10.20.0.254
10.20.0.1
10.20.0.9
10.19.0.19
10.18.0.18
10.13.0.1
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx