I don't think quote matching really belongs in matchbrackets.js . It is a different problem (doesn't concern itself with nesting). I'm not even sure what a language-independent quote matcher would look like (escaping rules differ). Maybe it could look for string tokens and find the matching start/end quotes on a series of subsequent string tokens?