I have a Javascript function that receives a string.
that string may have URLs in it, with, or without http:// or http/s:
example string:
This is an example string with www.cnn.com and http://microsoft.com"
my purpose is to take that string and inject anchor tags for the URLs such that they are clickable when injected as HTML to an html document.
Is there anything I can use that does this? some Jquery function?
No native jQuery function for this but regular expression can do this
Let me give point you to this blog post that will get you started. What it has is a regular expression (may seem rather complicated and complex, but is not that much) that can detect links and emails in strings so you’ll be able to find them and replace them with links that point to extracted URLs.
Maybe an even better expression (that I know I used in the past) has been published by Stackoverflow’s own Jeff Atwood. He also describes the whole URL situation in very much detail so you can decide whether this applies to your problem and how much or not.