Reputation: 9273
I have this regular expression:
var a = window.location.href.replace(/((.*)[&|?])(sessionid(=[^&]*))([&|#](.*))/, '$1$5');
That remove the sessionid from an example url like this:
http://...&parent_location=Test&abc=123&sessionid=q26bh6bkm8g49aeopem2obdm87igrsfe&...
The result will be:
http://...&parent_location=Test&abc=123&&...
My question is, if in that replace I can add the replace also for the parent_location
Upvotes: 0
Views: 68
Reputation: 174834
Use single regex with unnecessary capturing group removed.
str.replace(/([&?])(?:sessionid|parent_location)=[^&#]*(?=[&#]|$)/m, '$1')
Upvotes: 2
Reputation: 1
You can add several .replace methods in a row.
var a = window.location.href
.replace(/((.*)[&|?])(sessionid(=[^&]*))([&|#](.*))/, '$1$5')
.replace(/*statement*/);
Upvotes: 0