Fernando68 Fernando68 -4 years ago 305
C# Question

Check if a string in C# is a URL

This has been asked before here, but the answers are all PHP related.
Is there a similar and working solution using C#? Like a specific test class or routine?
I want to parse www.google.com or google.com or mywebsite.net etc... with or without prefixes.

Answer Source

C# has Regex as well, but this seems simpler:

bool isUri = Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute);

(Answered at Regular expression for URL)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download