For a templating engine, I am using regular expressions to identify content under brackets in a string. For example the regex needs to match {key} or
The best way to do this, especially if different brackets can have different meanings, is to split into 3 regular expressions:
var rx1 = /\[([^\]]+)]/;
var rx2 = /\(([^)]+)\)/;
var rx3 = /{([^}]+)}/;
These will match any text surrounded by [], (), and {} respectively, with the text inside in the first matched group.