JSFiddle - React, Tailwind, and code Playground
by Joe Saad
JavaScript
const str = "Can I check the {@restriction} status of {@client}?"
var found = [], // an array to collect the strings that are found
rxp = /{([^}]+)}/g,
//str = "a {string} with {curly} braces",
curMatch;
/*
while( curMatch = rxp.exec( str ) ) {
found.push( curMatch[1] );
}
console.log( found ); // ["string", "curly"]
*/
function getEntities(){
const found = []
const rxp = /{([^}]+)}/g
let curMatch;
while( curMatch = rxp.exec( str ) ) {
found.push( curMatch[1].replace('@','') );
}
console.log( found ); // ["string", "curly"]
}
getEntities(str);