0

I have common meta tags like that: <meta id="1" name="keywords" content="some keywords" />

My APP is writen in NodeJs and I need to extract all attributes like that:

[
 id: "1",
 name: "keywords",
 content: "some keywords",
]

I have folowing regex:

var attrsRegex = new RegExp(/\s(.*?)=["'](.*?)["']/gi);
var attrs = attrsRegex.exec('<meta name="author" content="Alza a.s." />');
console.log(attrs);

The code return only the first attribute:

[" id="1"", "id", "1", index: 5, input: "<meta id="1" name="keywords" content="some keywords" />"]

It seems the G flag doesnt work.?

JsFiddle HERE

StvnBrkdll
  • 3,924
  • 1
  • 24
  • 31
MakoBuk
  • 464
  • 2
  • 8
  • 18

0 Answers0