using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(http(s)?:\/\/.)?(www\.)?(?:[-a-zA-Z0-9@:%_\+~#=]{1,63}\.)+[a-z]{2,6}\b((?:[-a-zA-Z0-9@:%_\+~#?&//=""]+\.)*[-a-zA-Z0-9@:%_\+~#?&//=""]+)?";
string input = @"asfd http://gskinner.co.im asfd
asfd m.skinner.com asfd
asfd www.gskinner.com asfd
asfd http://www.gskinner.com asfd
asfd www.gskinner.com?a=1&b=2 asfd
asfd gskinner.com?a=""1""%203&b=2 asfd
asfd http://gskinner.com/a/b?c=3 asfd
asfd https://gskinner.com/a/b?c=3 asfd
asfd fdg.f.fg.gskinn.er.com/a/b?c=3 asfd
asfd ffgfgfgfgdfd/dfdfd.df asfd
asfd https://web.whatsapp.com/%F0%9F%8C%90/en asfd
asfd sdfsd://asdfw.asgd asfd
wealth.in..mutual sdf of 10k
wealth.Mutual,dfdfg sdf of 10k
wealth.Mutu/#index al of 10k
wealth.#MutualFundsSIP of 10k
wealth.$MutualFundsSIP of 10k
";
foreach (Match m in Regex.Matches(input, pattern))
{
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