正则
var pagename = /\/([a-zA-Z].+)/i.exec(location.href);
请问这个正则代替如下url
/Products&Services/abcd/
/Products&Services/dfgadf/
该怎么写
var pagename = /\/(/Products&Services/\w{3,50}/$)/i.exec(location.href);
这样好像也不对
------解决方案--------------------var t=['/Products&Services/abcd/','/Products&Services/dfgadf/'];
var pagename = /\/([a-zA-Z].+)/i;
for(var i in t){
alert(pagename.test(t[i]));
}
不明白你替代是什么意思 是将第一个值换成第二个值吗?
------解决方案--------------------var pagename = /\/(Products&Services\/\w{3,50}\/$)/i.exec(location.href);