Performance improvement on regex

Apparently this may be the cause of many CloudBees test failures, so trying it out.