I want to remove everything after Search with jQuery

-2

Here is the url:

... / search? type = APARTMENT% 2FAPTO + DUPLEX & area_de = area_at = & value_of = & value = neighborhood & neighborhood = Auxiliary & neighborhoods% 5B% 5D = AUXILIATOR & code = & send = Buscar & ord = & fespecial = & page = 1 & fespecial = novopronto & fespecial = novopronto

I would like to remove everything that comes after Buscar to perform a new query with jQuery.

$("#fe2").click(function(){

    var url         = window.location.href;
    ...
    
asked by anonymous 23.02.2015 / 16:49

1 answer

2

Here are two solutions:

Using split, however, you must enter Buscar again:

var url = window.location.href.split("Buscar")[0] + "Buscar";

Using regex:

var url = window.location.href.match(/.*Buscar/);
    
23.02.2015 / 16:53