我需要找到这网址的index.html前面的search这几个字
var str = 'http://a.com/b/c.php?s=/Search/index.html'; str.match(/(?!\?s=\/)\w+?(?=\/index\.html)/g); // ["Search"] //如果地址是这样的: var str = 'http://a.com/b/c.php?s=/Search/a/b/index.html'; str.match(/(?!\?s=\/)[\w\/]+?(?=\/index\.html)/gi); //["/Search/a/b"]
location.search.split('/')[1]
看看正则方法 截取 特定位置