Replace URL text to links

var text = 'I love http://www.sinapsa.co.il website :)'; text = text.replace(/((ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?)/gi,'<a href="$1">$1</a>'); // Result will look like: // I love <a href="http://www.sinapsa.co.il">http://www.sinapsa.co.il</a> website :)

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.