avoid empty pattern cause empty match