Added regex checking to rewrite.