Fix #524

It seems that .test mutates the regular expression, whereas .match does
not. Whoo JavaScript!