日期:2014-05-16  浏览次数:20347 次

怎么用正则判断网址中是否含有某get字符串
怎么用正则判断网址中是否含有某get字符串

var regex=new RegExp('index.php?main_page=index&cPath=2&sort=1&pp=5&pn=1');
regex.test('http://localhost/index.php?main_page=index&cPath=2&sort=1&pp=5&pn=1')

返回的结果是false,怎么办?

------解决方案--------------------
有些元字符需要转义的
var regex=new RegExp('index\\.php\\?main_page=index&cPath=2&sort=1&pp=5&pn=1');