How to remove part of the url?

A url search?fc%5B39%5D=on&fb%5B12%5D=on&p%5Bmin%5D=11&p%5Bmax%5D=53
How to remove the url that is highlighted, if it is present &fb%5B12%5D=on.
Need this so when the button is pressed, delete the url all these values and reloaded the page.
April 4th 20 at 13:04
2 answers
April 4th 20 at 13:06
Solution
let str = 'fc%5B39%5D=on&fb%5B12%5D=on&p%5Bmin%5D';
let newStr = str.replace(/\&fb%5B12%5D=on/g, ");

btn.onclick = () => window.location.href = newStr;
Let's say I replaced the % in the blank.
const str = window.location.href;
 const newstr = str.replace(/%/gi, ");
 console.log(newstr);


And how to insert an array in place?
For example
const array = ['fb%5B28%5D=on', 'fb%5B12%5D=on', 'fb%5B13%5D=on'] // and so on
- kaleb_Legros commented on April 4th 20 at 13:09
@kaleb_Legros, and in what form you want to insert an array instead of %? As soon as I solve the problem with the translation of the array in the desired view (row) response question with replacement. Because instead of " you need to paste the row and all - Hyman commented on April 4th 20 at 13:12
@Hyman, I have all starts on fb in the url is the brand selected. It may be a few values in the 1 url.

I want to make a button where when you press on it, all the fb was removed with a url. - kaleb_Legros commented on April 4th 20 at 13:15
@kaleb_Legros, well, write a regular season that will find the text and delete.
To write and test the regular season use the service https://regex101.com - Hyman commented on April 4th 20 at 13:18
@HymanAbout the regular season - all well said. I should add that this Velma complex and very powerful tool. - Cortney_Thomps commented on April 4th 20 at 13:21
@Hyman,
Yes did everything perfectly, thank you
$(".fcats li.all_brands_filter").click(function() {
 const str = window.location.href;
 const newstr = str.replace(/&fb%5B\d{0,100}%5D=on/gi, ");

 if(str) {
 window.location = newstr;
}

});
- kaleb_Legros commented on April 4th 20 at 13:24
April 4th 20 at 13:08
?url.replace('&fb%5B12%5D=on', ")

Find more questions by tags JavaScript