Hi,
I have this at the moment, (I found the code on here).
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
someText.replace(exp, "<a href='$1'>$1</a>");
It will replace any http://URL in someText with a proper <a href>
But i also require it to match www. without the http. I found this RegEx on RegEx Lib.
((http\://|https\://|ftp\://)|(www.))+(([a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9%:/-_\?\.'~]*)?
And i tested in on the RegEx checker site, http://www.nvcc.edu/home/drodgers/ceu/resources/test_regexp.asp
It matches the strings i want. But when i put it into my exp var, JavaScript is blowing up and causing an error.
I even tried newing it up as a new RegExp like so.
var exp = new RegExp(((http\://|https\://|ftp\://)|(www.))+(([a-zA-Z0-9\.-]+\.[a-zA-Z]{2,4})|([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}))(/[a-zA-Z0-9%:/-_\?\.'~]*)?);
But the same thing happens.
Any ideas what i am doing wrong?
Thanks, Kohan