tags:

views:

36

answers:

1

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=rid_value to querystring

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