Regular Expressions 101

Community Patterns

There does not seem to be anything here

Community Library Entry

0

Regular Expression
PCRE (PHP <7.3)

/
([A-Za-z][A-Ha-hK-Yk-y]?[0-9][A-Za-z0-9]? ?[0-9][A-Za-z]{2}|[Gg][Ii][Rr] ?0[Aa]{2})
/
gms

Description

Matches the following UK post code formats:

  • A9 9AA
  • A9A 9AA
  • A99 9AA
  • AA9 9AA
  • AA9A 9AA
  • AA99 9AA
Submitted by anonymous - 6 years ago