1
I’m building a regular expression to validate plane registrations. They are always in this sequential format:
- 2 capital letters A to Z
- Hyphen
- 3 numbers
Totaling 6 characters.
I did the following structure, but I can’t validate it:
^[A-Z]{2}-[0-9]{3}$
The test string is:
AB-123
How can I validate this string in this format? Remembering that:
- AB123 is invalid
- A1234 is invalid
- A-1234 is invalid
- AB-1234 is invalid
--- EDIT It was just a flaw in the validator, when doing the test again, gave match on the correct string.
Seems correct, as is html/js?
– rray
Confirming that it works: https://regex101.com/r/cv7G4V/1
– bfavaretto
Strange, in the same validator (regex101) that was testing, did not give match in any circumstances... Now, when opening the validator again, it worked correctly.
– Maykel Esser
The validator presented as an error, but it was only an instability. The REGEX presented works.
– Maykel Esser
^[A-Z]{2}- d{3}$
– R.Santos