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;
}
精彩评论