move regex into a separate class to make testing easier

Implements #28