var a="asdand andor and ope(and)and asd and(1)"; var b=a.replace(/\band\b/g,"&&"); console.log(b); alert(b);