minor refactoring for regexp helpers