Refactors regex for speed.