I need to search through a string entered by a user and convert anything that is plain text and resembles a url into a url.
Im not concerned with how to construct the URL, more how to determine if the text is actually a url. I was thinking about a regular expression (see How to replace plain URLs with links?), but ideally would like a solution that is more readable.
I suppose I would need to search for instances of http
or www
and wrap the string up until the next space in an anchor
tag.
Does anyone have any pointers, especially seen as urls can be so varied now a days?
EDIT:
A user enters text into an input that is submitted, when displayed on screen I need to check their comment for any possible links and convert them to a hyperlink.