Why am I not able to grab the subpattern? The console displays undefined
when I am expecting hello
to be output. If I change matches[1]
to matches[0]
I get {{hello}}
. So, Why can I not access the subpattern?
var str = "{{hello}}";
var matches = str.match(/{{(.+)}}/ig);
console.log(matches[1]);