Extract regexes

Extracted the regex checks to small helper functions