I want to control the format of codes users enter to identify cases to three CAPITAL letters followed by 3 numbers eg:
The regex I have in place to do this is:
This nearly works! The problem with it is that it lets me enter as many CAPITAL letter as I like ie it doesn’t give an error if ABCD123 is entered or ABCDE123 is entered.
What am I doing wrong?
I think you might just be missing the “match from the beginning” marker,
^. I would try this expression
or in other words just inserting the
^ at the beginning of your expression. This should make it match from the beginning just like
$ makes it match all the way to the end. The default behavior without the beginning/end markers is to match if the pattern is found anywhere in the the string.