[Solved] how to remove the particular string from the url and update it [closed]


You can use js split method https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/split

var url="www.abc.com/xyz";
var arr = url.split("https://stackoverflow.com/");
var newUrl = arr[0];
console.log(newUrl);
/*if string the url is 'www.abc.com/xyz/pqr' and you want only 'www.abc.com/xyz' thn?*/

var url="www.abc.com/xyz/pqr";
var arr = url.split("https://stackoverflow.com/");
if(arr.length > 1){
	arr.pop();
}
var newUrl = arr.join("https://stackoverflow.com/");

console.log(newUrl);

2

solved how to remove the particular string from the url and update it [closed]