Angular ng-pattern regex code for US Zipcodes and Canadian Postal codes [closed]
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago . I could anybody help me out? I am looking for some regexp to use to validate US Zip codes and Canadian Postal codes in AngularJS 回答1: This should work for you: ^(\d{5}(-\d{4})?|[A-Z]\d[A-Z] *\d[A-Z]\d)$ http://regex101.com/r/nO4zF5 Remove the ^ and $ anchors if you don't want to