 var msg=document.getElementsByName("title"); for(var i=0;i <msg.length;i++){ var oldtext=document.getElementsByName("title")[i].innerHTML; var newtext=oldtext.replace(/(^|[\n ])([\w]+?:\/\/[^ ,\"\n\r\t<]*)/ig,"$2"); newtext=newtext.replace(/@(.+?)@(.+?)/g,'$2'); document.getElementsByName("title")[i].innerHTML=newtext; }