我有这样的常见元标记:
<meta id="1" name="keywords" content="some keywords" />
我的APP在NodeJ中编写,我需要提取所有属性:
[
id: "1",
name: "keywords",
content: "some keywords",
]
我有以下正则表达式:
var attrsRegex = new RegExp(/\s(.*?)=["'](.*?)["']/gi);
var attrs = attrsRegex.exec('<meta name="author" content="Alza a.s." />');
console.log(attrs);
代码只返回第一个属性:
[" id="1"", "id", "1", index: 5, input: "<meta id="1" name="keywords" content="some keywords" />"]
似乎G
标志无效。?