Regexp

A (RegExp) Catastrophe

Have you ever come across the term “Catastrophic Backtracking” in relation to regular expressions? Well I came face-to-face with it’s fury the other day while researching a bug in an old CMS module which I was trying my best to fix.

It started out with an outrageous claim from a QA tester that he could crash Chrome by typing in a large number of characters in to a text box. I tested it out and to my surprise the problem was worse than he realised and it all stemmed from a particular regular expression being used to validate an email address. It looked like this: