The findLinks() function let's you highlight links in a string, which start with "http" or "https", but some code modification can increase its capabilities.
The source code for this function was conceived through Sharikul Islam's PHP version at http://sniply.co/1e2e6c24ac.
Syntax:
findLinks(source);
Example:
<html> <head>
<scripttype="text/javascript"> var string_with_links ="Follow FuncJS on Twitter at http://twitter.com/FuncJS"; var detect_links = findLinks(string_with_links);
echo(detect_links); //this will output "Follow FuncJS on Twitter at <a href="http://twitter.com/FuncJS">http://twitter.com/FuncJS</a>"
</script> </head> </html>
Use the demo below to see how this function is going to function on a live webpage. Enter some words with at least one link (starting with "http" or "https") and click "Show links" to see the inputted text appear below with any links highlighted.