[英]Replace with regular expression in Javascript
我有這個正則表達式:
var a = window.location.href.replace(/((.*)[&|?])(sessionid(=[^&]*))([&|#](.*))/, '$1$5');
這樣可以從示例網址中刪除sessionid,如下所示:
http://...&parent_location=Test&abc=123&sessionid=q26bh6bkm8g49aeopem2obdm87igrsfe&...
結果將是:
http://...&parent_location=Test&abc=123&&...
我的問題是,如果在該替換中,我還可以為parent_location
添加替換
您可以連續添加幾個.replace方法。
var a = window.location.href
.replace(/((.*)[&|?])(sessionid(=[^&]*))([&|#](.*))/, '$1$5')
.replace(/*statement*/);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.