I am trying to make a match for a certain string that is located in the url so that when it is true just do "/ clothes /" and when it is the value do "1,2" via jquery .. ex: / filter / clothing / sex / 10.10 / color / 20.31
var url = "/filtro/";
var regex = /roupas/gi;
var nomeanterior = $(this).attr('name');
$("input:checkbox:checked").each(function() {
if (nomeanterior.match(regex)) {
url = url + "/" + $(this).attr('name') + "/" + $(this).val();
console.log($(this).val());
} else {
url = url + "," + $(this).val();
}
});
console.log(url)
var locationurl = window.location.href.replace(/\/filtro\/.*/gi, "") + url;
//window.location = locationurl;
console.log(locationurl);
return false;