I need to get the text (if any) between curly brackets. I did find this other post but technically it wasn\'t answered correctly: Regular expression to extract text between
To extract all occurrences between curly braces, you can make something like this:
function getWordsBetweenCurlies(str) {
var results = [], re = /{([^}]+)}/g, text;
while(text = re.exec(str)) {
results.push(text[1]);
}
return results;
}
getWordsBetweenCurlies("Some random {stuff} in this {sentence}");
// returns ["stuff", "sentence"]