我有这样的正则表达式:用正则表达式替换在Javascript
var a = window.location.href.replace(/((.*)[&|?])(sessionid(=[^&]*))([&|#](.*))/, '$1$5');
,从一个例子URL删除会话ID是这样的:
http://...&parent_location=Test&abc=123&sessionid=q26bh6bkm8g49aeopem2obdm87igrsfe&...
结果将是:
http://...&parent_location=Test&abc=123&&...
我的问题是,如果在那个替换我可以添加替换也为parent_location
什么是您预期的输出? – anubhava
1.将URL /查询字符串解析为数组/对象。 2.根据需要操作数据。 3.重新格式化为一个URL。 - 比regexen好得多。 – deceze
此结果:http://...&& abc = 123 && ...我也不想删除parent_location查询字符串,将不胜感激也删除&不需要 – Piero