I am currently trying to parse parameters from a path to a JavaScript file (inside a script tag). At the moment I know which parameters I expect to be there but instead of looking for the expected params I would rather like to just extract all params given.
包括 Java印文件在内的文字标签实例:
<script type="text/javascript" src="https://url/widget.js?param1=A¶m2=bb></script>
在我刚刚做这项工作的时候(每个参数通常):
jQuery( script ).each(function() {
var script = this;
if (!script.src) {
return;
}
var matchKey = script.match(/https://url/widget.js?param1=([A-Z]+)/);
if (matchKey) {
oSettings.param1 = matchKey[1];
}
}
因此,我所需要的是一条可以提取参数名称和所包括管道的价值的节奏。
感谢援助!