non-capture group still showing in match

The entire match will always be group 0, you need to access that specific group (group 1 in this case since the first group is non-capture), you can do it like this:

var str = "<p model="cat"></p>";
var regex = /(?:model=")(.*)(?:")/g
var match = regex.exec(str);
alert(match[1]); // cat

Fiddle

Also, I suppose you are probably wanting several matches within str, you could do that like this:

var str = "<p model="cat"></p><p model="dog"></p><p model="horse"></p>";
var regex = /(?:model=")([^"]*)/g
var matches = [];
var match;
while (match = regex.exec(str)) {
  matches.push(match[1]);
}
alert(matches); // cat,dog,horse

Fiddle

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)