Fix comparison for regexp deepEqual

This PR replaces #394 with a feature branch on my end and a simplified commit history.

I've not added the additional tests yet requested in #394, but I'm working on them now. Like the old PR it should close #392 when it's done.