Add tests for the new regex stuff.

And, you know, fix all the issues the tests found.