Regular Expressions 101

Community Patterns

Even better UK postcode regex

0

Regular Expression
PCRE (PHP <7.3)

/
^([a-zA-Z]{1,2}\d{1,2})\s{1,1}\*?(\d[a-zA-Z]{2})$
/
gmi

Description

includes mandatory whitespace for UK postcodes

credit goes to the original version, this is improved with mandatory whitespace.

Submitted by anonymous - 4 years ago