Lets say I have a text such as this
“This is a long text. It contains 150 characters. You can find more about this text on this link http://www.somewebsite.com/RDFCCSDVDS“.
So in above text I want to find that link and convert it into a link so that when user clicks on it, the user will be taken directly to this website.
How can I achieve this goal?
I suspect that I could much improve upon this, though at the minute this is the best I can offer (albeit I think that some kind of replace might work more efficiently):
JS Fiddle demo.
A slightly improved version of the above (but good lord, it’s ugly…):
JS Fiddle demo.
I’m not quite sure what to do about quoted links, though (text such as
"http://google.com", for example); and, honestly, I think that regex is probably the far, far better approach to this problem.