private static bool MatchClass(char c, char cl) { bool res; switch (cl) { case 'a': res = Char.IsLetter(c); break; case 'c': res = Char.IsControl(c); break; case 'd': res = Char.IsDigit(c); break; case 'g': throw new System.NotImplementedException(); case 'l': res = Char.IsLower(c); break; case 'p': res = Char.IsPunctuation(c); break; case 's': res = Char.IsWhiteSpace(c); break; case 'u': res = Char.IsUpper(c); break; case 'w': res = Char.IsLetterOrDigit(c); break; case 'x': res = IsXDigit(c); break; case 'z': res = (c == '\0'); break; /* deprecated option */ default: return(cl == c); } return(res); }