I want a regex expression that will match;
- www
- http
- https
It should make only urls in the string clickable. What is the best way to do this?
What I have now is this, but this doesn't match www. Also, I don't know how to make the entire text visible in the label, not just the links. I guess this could be done with some space separation and recursive loops, if someone has a good idea I'd be happy to hear it.
Regex r = new Regex(@"(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?");
// Match the regular expression pattern against a text string.
if (valueString != null)
{
Match m = r.Match(valueString);
if (m.Success)
{
labelHtml = "<a href=\"" + m.Value + "\">" + m.Value + "</a>";
}
}
((Label)control).Text = labelHtml;