Regular Expressions 101

Community Patterns

Community Library Entry

3

Regular Expression
ECMAScript (JavaScript)

/
^(\d{5})(?:-?(\d{4}))?$
/

Description

This pattern matches the US Postal Code format and captures the seperate parts; basic and +4.

Submitted by anonymous - 9 years ago