News for hackers. Stuff that matters.
Re:ECMAScript regular expressions are getting better (2017) by wpietri on Wednesday November 28, 2018 @10:36AM (#18552332)
People have a number of good suggestions, but let me suggest unit tests as one excellent way to make regexes maintainable.

The maintenance problem for me with regular expressions is that when I write them I have carefully studied a variety of inputs and then make something that matches. Typically I will also have tested it as I go, trying out various known strings. But then a year later I have forgotten all the cases, and I have to somehow decompress them from the regex.

If I save my experiments in well-named unit tests, though, it's much easier for me to figure out my original intent, and to see whether the new case I'm thinking about is covered.

There are no comments on this comment yet.