I want to do preliminary check if entered string looks like Vehicle Identification Number (VIN). I know what it consists of 17 letters and digits, but letters I, O and Q are not allowed inside VIN, so I use this regular expression:
^[0-9A-Z-[IOQ]]{17}$
Now if I check a string like 1G1FP22PXS2100001 with RegularExpressionValidator it fails, but CustomValidator with this OnServerValidate event handler
Regex r = new Regex("^[0-9A-Z-[IOQ]]{17}$");
args.IsValid = r.IsMatch(TextBox1.Text);
works well.
Experiments show what RegularExpressionValidator doesn't support Character Class Subtraction, but Regex class does.
Now I am interested why do these two .NET classes use different regex flavors? Is it documented somethere?
See Question&Answers more detail:os