And be careful, since the most of the examples floating around on the
web only show how to validate a subset of valid URLs, which may or may
not be acceptable depending on your needs.
I am using the following:
Boolean valid = Regex.IsMatch(context.PropertyValue, @"((?<=\()
[A-Za-z][A-Za-z0-9\+\.\-]*
![Frown :( :(](/styles/default/custom/smilies/frown.gif)
[A-Za-z0-9\.\-_~:/\?#\[\]@!\$&'\(\)\*\
+,;=]|%[A-Fa-f0-9]{2})+(?=\)))|([A-Za-z][A-Za-z0-9\+\.\-]*
![Frown :( :(](/styles/default/custom/smilies/frown.gif)
[A-Za-
z0-9\.\-_~:/\?#\[\]@!\$&'\(\)\*\+,;=]|%[A-Fa-f0-9]{2})+)");
Based on the following Regex:
http://blog.dieweltistgarnichtso.net/constructing-a-regular-expression-that-matches-uris
Not sure if it is the best one but it seems ok.
Basically in my case I am adding Slides (Images) to site in a CMS.
Each image can have a link to some site.
I want to be sure that the url inserted has a valid format.
Thanks,
Miguel