Reputation:
I need to check that value takes the form (one or two or three any numbers and one or potential two any letters) example: 1B, 1AB, 45C, 791AS, 2, 324. For now I have something like this:
\d{1,3}[A-Z]{1,2}?/
but it does not work. What am I doing wrong?
This is not a duplicate of this question; the questions may relate to the same mechanism but this one contains a concrete example and a specific regex that is not working the way I expect.
Upvotes: 0
Views: 69
Reputation: 33186
Why make the part for the characters so hard? You can set the occurrences to {0,2}
:
\d{1,3}[A-Z]{0,2}
Upvotes: 1