My goal is to validate zip codes or pin codes in address fields. As a result, I am working on writing a regular expression that only allows characters a-z
(upper and lower case), digits 0-9
, round brackets (e.g. ()
), hyphens -
, and spaces. However, there are some specific rules that must be followed, such as a single white space not being allowed in the first position, and two or more white spaces not being allowed.
Here are some examples of invalid entries:
1254588
125 255
((125)) 255
125--255
(125) (255)
125>2458
EL$ 2458
@L$ 2458