Fix performance for new regexp engine