This regular expression: /\{(\w+)\}/g
returns ["{name}", "{color}"]
and ignores my parenthesis around (\w+)
Why doesn't this work? What is the correct regular expression?
Token replacement:
const item = {
name: 'foo',
color: 'bar'
};
let str = `'{name} - {color}'`
console.log( str.match( /\{(\w+)\}/g ) );