Regex are hard to write, and even harder to read


Regex are hard to write, and even harder to read.

A technique that helps:

1. Declare the regex as a well-named const.
2. Write automated tests on the regex.

This assures the regex works as expected. And it documents the regex’s expected behavior for others.

View original on X