Although I don't consider this a "hotspot" I agree that the current approach could be optimised. I decided to go with a "primitive comparison". See: http://jsperf.com/regex-test-vs-array-indexof/2