using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^(?:[a-z][0-9a-z-.+]*:\/\/)?((?:(?:[a-z\u00a1-\uffff0-9_]+-?)*[a-z\u00a1-\uffff0-9_]+)(?:\.(?:[a-z\u00a1-\uffff0-9_]+-?)*[a-z\u00a1-\uffff0-9_]+)*(?:\.(?:[a-z0-9\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/.*)?(?:\?.*)?(?:\#.*)?$";
string input = @"socks://www.example.com
10.1.1.1
10.1.1.2/4
10.1.1.3/0
10.1.1.0/8
10.1.1.5/32
10.1.1.6/35
10.1.1.7/36000
10.1.1.8/abcd
10.1.1.9-10.1.1.10
user:pass@zxuz.com
user@proxy.brew.opendnstest.com/customBlockUserInfo
user:@proxy.brew1.opendnstest.com/customBlockUserInfo
user:password@proxy.brew2.opendnstest.com/customBlockUserInfo
ftp://cnn.example.com&story=breaking_news@foobar.com/top_story.htm
foo.com:8080/bar/baz
asdfasdf.com/foo/b%20ar
https://example.com/archive/*/http://somesite.com
";
RegexOptions options = RegexOptions.Multiline | RegexOptions.IgnoreCase;
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