Refactored regex validator (fixes #37).
Improved tests.