Fix bug when parsing character sets in patterns