Imagine something like this:
some of <word>;
<space>;
capture {
1 to 9;
2 of <digit>;
}
should match "Econ 101" capturing "101";
should not match "305";
should not match "Physics 022"
If you have the ability to embed tiny unit tests in your regex declaration, then this could substantially help both to catch regressions and to document the intent behind the regex. The unit tests would be run at compile time, raising something akin to a syntax error if they fail (with clear output as to why they failed, to make it easier to fix).
Imagine something like this:
If you have the ability to embed tiny unit tests in your regex declaration, then this could substantially help both to catch regressions and to document the intent behind the regex. The unit tests would be run at compile time, raising something akin to a syntax error if they fail (with clear output as to why they failed, to make it easier to fix).