
例如:
有个url为http://www.dd.com/?class=3
在js中
var str_url=window.location.href;
var str_class1=/class=/;
str_class1.exec(str_url);
var str_class=RegExp.rightContext;
这样就能获取class的参数了,请问代码中的"/"除了作为数学运算符和解释说明之外还有什么作用,最好以上每一步都解释一下,谢谢
var str_url=window.location.href; '获得当罩历前url
var str_class1=/class=/; '定义正则表达差橡式
str_class1.exec(str_url); '搜索字段str_url,
var str_class=RegExp.rightContext; '返回结果3,rightContext功能:表示最物庆搜近一次匹配位置的前一次对应的输入字符串,只读。
RegExp看到这个就要立刻反应:“正则表达式”