Regular Expressions 101

Even better UK postcode regex

Open Workspace
  • PCRE (Legacy)
  • Match
0

Regular Expression

/
^([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