JSFiddle - React, Tailwind, and code Playground
JavaScript
let str = 'this is {foo} afoo {bar} sentence';
let matches = str.match(/\{(\w+)\}/gi).map(match => match.substring(1, match.length - 1));
console.log(matches);
let str = 'this is {foo} afoo {bar} sentence';
let matches = str.match(/\{(\w+)\}/gi).map(match => match.substring(1, match.length - 1));
console.log(matches);