function example(){
var quantity = "http://www.example.com/index.php?brandid=b%123&quantity=20";
quantity = quantity.replace(-what regular expression should i user-, "quantity=50");
}
我只想将链接中的
quantity=20
替换为 quantity=50
。但我尝试了一些正则表达式,例如:replace(/quantity=[^\d]/g,"quantity=50");
replace(/quantity=[^0-9]/g,"quantity=50");
所以我想从正则表达式方面的专业知识中得到一些帮助来帮助我 =) 谢谢
最佳答案
replace(/quantity=[\d]+/g,"quantity=50")
关于javascript - 正则表达式 Javascript 替换,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8889156/