I can't seem to understand your regex. Can it not be `/<\w-\w+>|<\w+>|./`? Why are `?` and `\n` needed?

Also, tiny nit, regexp.exec seems to be faster http://jsperf.com/string-match-vs-regexp-exec. But don't care much.