moved some regexp logic into a helper class to make testing easier