开发者

Update URL parameter

开发者 https://www.devze.com 2023-03-31 15:10 出处:网络
I have the following string: http://www.website.com?a=11开发者_StackOverflow中文版1&b=2222&d=3333

I have the following string:

http://www.website.com?a=11开发者_StackOverflow中文版1&b=2222&d=3333

How can I take this string and update the b parameter value with 4444?


var str = 'http://www.website.com?a=111&b=2222&d=3333';
str.replace(/([&\?]b=\d+/,"$1b=4444")


String.replace(/b=([^&]*)/, "b=4444")


var myString = "http://www.website.com?a=111&b=2222&d=3333".replace("b=2222","b=4444")
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号