i have any issue where i want to remove url parameters when on click the div , while some parameters are in words and some are numbers that containing %20 , i am not able to remove those ones , can you please help me .
my url is https://www.schooleducation.com/onlin/courses/?filter=8%27%20-%2015%27
i want to remove 8' - 15' url parameter value from the url when onlclick here is my code
$('.fileter-container').once('filter-click').on('click', function () {
var key = $(this).data('key');
$(this).remove();
var url = 'https://www.schooleducation.com/onlin/courses/?filter=8%27%20-%2015%27'
var re = new RegExp("&filter=\\d+");
var newurl= url.replace(key, '');
// var newurl = url.split('?')[0];
location.replace(newurl);
});