var vari = "oferta"; var re = new RegExp(vari); if (location.href.search(re) == 0) { alert("si"); }