No matter of regex pattern, there's inbuilt function:
Uri.IsWellFormedUriString Method (String, UriKind) (System)[
^]
Exmaple:
List<string> uris = new List<string>(){"www.com", "http://ww.try.net", "http://winner.com", "url = null"};
var result = uris.Select(x=> new {Uri = x, IsValid = Uri.IsWellFormedUriString(x, UriKind.Absolute)});
foreach(var u in result)
{
Console.WriteLine("'{0}' is{1}valid", u.Uri, u.IsValid ? " ":" NOT ");
}
Result:
'www.com' is NOT valid
'http://ww.try.net' is valid
'http://winner.com' is valid
'url = null' is NOT valid
In case, you want to use Regex instead, you can use this:
^http(s)?://([\w-]+.)+[\w-]+(/[\w- ./?%&=])?$