-
Notifications
You must be signed in to change notification settings - Fork 107
Open
Description
The two leftmost digits of a Spanish postal code correspond to the province codes. There are only 52 provinces, whose numbers range from 1 to 52.
Therefore, the regular expression could be a bit more precise, by allowing only valid province codes:
^(?:0[1-9]|[1-4]\d|5[0-2])\d{3}$
Source: https://en.wikipedia.org/wiki/Postal_codes_in_Spain
This is also done in Andorra "AD", where the third digit is one of the seven parishes, which is correctly limited by [1-7] in the regex.
Metadata
Metadata
Assignees
Labels
No labels