UK Postcode
intermediateMatches UK postcodes in standard format.
postcodeukpostalvalidation
Pattern
/[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}/giTry It
0 of 8 strings matched
Explanation
Matches UK postcodes: 1-2 letters, digit, optional letter/digit, optional space, digit, 2 letters. Covers all UK postcode formats.
Test Strings
Matching
- SW1A 1AA
- EC1A1BB
- W1A 0AX
- M1 1AE
Non-matching
- 12345
- ABCDE
- SW1A1
- 123 456
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /[A-Z]{1,2}\d[A-Z\d]?\s?\d[A-Z]{2}/gi;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);