Validationflags: gi
UK Postcode
Match UK postcodes in the common outward + inward format (e.g. SW1A 1AA, EC1V 9LB).
Try it in RegexPro →Available in
Pattern
regexengine-agnostic
[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2} (flags: gi)Raw source: [A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}
How it works
1–2 letters, 1 digit, optional letter/digit, optional space, 1 digit, 2 letters. Case-insensitive flag handles lower and mixed case input.
Examples
Input
SW1A 1AAMatches
SW1A 1AA
Input
EC1V 9LBMatches
EC1V 9LB
Input
B33 8THMatches
B33 8TH
Common use cases
- •UK address validation
- •Geocoding integration
- •Delivery route planning
- •Audience targeting by region
Related patterns
Canadian Postal Code
ValidationMatch Canadian postal codes in the A1A 1A1 or A1A1A1 format with valid first-letter prefixes.
Email Address Validation
ValidationMatch and validate email addresses in the standard user@domain.tld format.
International Phone (E.164)
ValidationValidate phone numbers in ITU-T E.164 international format: a + sign followed by 2–15 digits, first digit non-zero.
US Phone Number
ValidationMatch US phone numbers in common formats: (555) 867-5309, 555-867-5309, 5558675309.