Fix typo in regular expression

Correctly close end brace. Improve performance slightly in
artificially generated worst case.
Merge pull request #754 from ElliotJH/fix-regex-typo

Fix typo in regular expression