Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
^(\d{5}(-\d{4})?|[A-CEGHJ-NPRSTVXY]\d[A-CEGHJ-NPRSTV-Z] ?\d[A-CEGHJ-NPRSTV-Z]\d|[A-CEGHJ-NPRSTVXY]\d[A-CEGHJ-NPRSTV-Z])$
/
i

Description

Possible Formats: N8X 3T7 N8X 80021 80021-1234

Submitted by Abdul Nasir - 8 years ago