3 ms·
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
by wpietri 8y ago
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.