Is there a way to replicate this PHP snippet in JQuery or Javascript...
Something like this should do:
var re = /{[^}]*}/g;
var s = '{foo},bar,{fum}';
alert(s.match(re)); // ['{foo}','{fum}']
but you may not want the "{}" included.
var re = /{([^}]*)}/g;
var s = '{foo},bar,{fum}';
var a = [];
var b;
while (b = re.exec(s)) {
a.push(b[1]);
}
alert(a); // ['foo','fum'];
There's bound to be a way to do it with a single regular expression and no loop.