I have a string in javascript. I need to pick all strings between "{"
and "}"
.
Example:
QUO-{MM/YYYY}-{SERVICEGROUP}
Here i need to grab strings between {}
.
I have a string in javascript. I need to pick all strings between "{"
and "}"
.
Example:
QUO-{MM/YYYY}-{SERVICEGROUP}
Here i need to grab strings between {}
.
Use regular expression /{(.*?)}/g
:
var re = new RegExp('{(.*?)}', 'g');
result = re.exec('QUO-{MM/YYYY}-{SERVICEGROUP}');
Will output: ["{MM/YYYY}", "MM/YYYY"]
Edit:
'QUO-{MM/YYYY}-{SERVICEGROUP}'.match(/{(.*?)}/g);
Will output: ["{MM/YYYY}", "{SERVICEGROUP}"]