Fernando68 Fernando68 - 10 months ago 81
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)