added support for brace wrapped result references; also better abstracted that regExp