Factored out regex.py