More robust character class parser.