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 or [element
var rx = /\[[^\]]+\]|\{[^}]+\}|<[^>]+>/;