I would like to capture a string that meets the criteria:
may be empty
if it is not empty it must have up to three digits (->
\d{1,3})- may be optionally followed by a uppercase letter (
[A-Z]?) - may be optionally followed by a forward slash (i.e.
/) (->\/?); if it is followed by a forward slash it must have from one to three digits (->\d{1,3})
Here's a valid input:
- 35
- 35A
- 35A/44
Here's invalid input:
- 34/ (note the lack of a digit after '/')
I've come up with the following ^\d{0,3}[A-Z]{0,1}/?[1,3]?$ that satisfies conditions 1-3. How do I deal with 4 condition? My Regex fails at two occassions:
- fails to match when there is a digit and a forward slash and a digit e.g .
77A/7 - matches but it shouldn't when there isa digit and a forward slash, e.g.
77/
