This should be easy, but I’m not sure how to best go about it. I have a WinForms app that lets the user type in long descriptions. Occaisionally, they would type in URLs, and the RichTextBox would recognize them and make them clickable when displayed.
I’m moving the app to the web, and I’m not sure how to make those same URLs clickable. Is there some semi-automatic way to convert ‘http://www.google.com‘ or ‘www.google.com’ to clickable links? Do I have to resort to RegEx matching?
It’s actually a very difficult problem. You can get close, but not perfect, with regular expressions. There’s a very nice breakdown of potential regex patterns to consider here: http://www.regexguru.com/2008/11/detecting-urls-in-a-block-of-text/
The last one he lists seems like it’s probably good enough for most purposes: