I'm pretty unfamiliar with RegExp, and Im trying to implement it to detect urls in strings. The one regexp I want to use is this one (please don't provide your own):
/(((http|ftp|https)://)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)/g
And replace all the matches with this:
<a href="$1">$1</a>
If you visit http://gskinner.com/RegExr/ with that example and use it in the replace, you'll see it works flawlessly, but it's impossible to build a working solution with this in javascript.
var text = "hi, demo link http://stackoverflow.com is a great website"
//regexp magic
//expected result:
textWithLink ="hi, demo link <a href="http://stackoverflow.com">http://stackoverflow.com</a> is a great website"
var re = new RegExp('(((http|ftp|https)://)?[\w-]+(\.[\w-]+)+([\w.,@?^=%&:/~+#-]*[\w@?^=%&/~+#-])?)', 'g');/.../g