0

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.

Vlad274
  • 6,514
  • 2
  • 32
  • 44

1 Answers1

1

Why make the part for the characters so hard? You can set the occurrences to {0,2}:

\d{1,3}[A-Z]{0,2}
Jerodev
  • 32,252
  • 11
  • 87
  • 108