开发者

How to update/append a string with javascript?

I want to check whether in querystring there is something like [?|&]rid=\d,

if there is,I want to update the \d with a specific rid_value,

else I want to append &rid开发者_Go百科=rid_value to querystring


pattern = /rid=\d/;
if(pattern.test(querystring)){
    querystring = querystring.replace(/rid=\d/, 'rid=' + rid_value);
} else{
    querystring = querystring + '&rid=' + rid_value;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜