var url = 'http://xxx.com/index.php?page=1';
url = url.replace(/(http:\/\/xxx\.com\/index\.php\?page=)(\d+)/,function(){
return arguments[1]+'2';
});
不建议使用正则,可使用location对象提取page参数进行处理
var url="http:\/\/xxx.com/index.php?page=";
var thisUrl=url+2;
如果非用正则:
var url="http:\/\/xxx.com/index.php?page=1";
var reg=/page\=[\d]+/i;
var thisUrl=url.replace(reg,"page="+2);
亲,一定要用正则吗?用字符串截取很简单,