flip strings for correct regex matching