I want to control the format of codes users enter to identify cases to three CAPITAL letters followed by 3 numbers eg:
ABC123
The regex I have in place to do this is:
regex(., '[A-Z][A-Z][A-Z][0-9][0-9][0-9]$')
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?
Thanks
Simon
Hi Simon,
I think you might just be missing the "match from the beginning" marker, ^
. I would try this expression
regex(., '^[A-Z][A-Z][A-Z][0-9][0-9][0-9]$')
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.
Cheers,
Danny