I'm running a small javascript replace to replace text on a button click and I can't see why it's not working. Could anybody tell me what i'm doing wrong?
$("#button").click(function() {
$("#editme").value = replaceLinks($("#editme").val());
})
function replaceLinks(text) {
var exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
return text.replace(exp,"[url=$1]$1[/url]");
}