如果我在页面的标记中有以下内容:
cmCreatePageviewTag("Category: View All Mens (29103)", "29103", null, null, "10151");
如何在括号之间提取参数,以便将以下内容存储在变量中:
"Category: View All Mens (29103)", "29103", null, null, "10151"
答案 0 :(得分:-1)
var regExp = /[a-zA-Z0-9_]+\((.+)\);/;
var str = 'cmCreatePageviewTag("Category: View All Mens (29103)", "29103", null, null, "10151");';
var details = regExp.exec(str);
console.log(details[1]) // "Category: View All Mens (29103)", "29103", null, null, "10151"
正则表达式搜索任何字母数字字符或下划线(函数名称),后跟(
,后跟任意数量的字符(参数),后跟);
。