How to regex extract uk postcodes and phone numbers from excel text cells
- Step 1Upload the address or contact file — Drop the
.xlsxor.csvwhose first sheet holds the column with embedded postcodes or phone numbers. Only the first sheet is read. - Step 2Enter the source column header exactly — Type the header verbatim, case included (
Address,Contact Notes). A mismatch produces a silent all-empty column. - Step 3Paste the postcode or phone regex — UK postcode:
([A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}). UK phone:(\+44[\s\d-]{9,12}|0[\d\s-]{9,12}). The capture group keeps just the value. - Step 4Name the output column — Use
postcodeorphone— not an existing header, which would be overwritten. Default isextracted. - Step 5Run on Pro and check coverage — Requires Pro or higher. Compare the change count to your row total; uppercase-only postcode patterns commonly miss lower-case entries — fix the case handling and re-run.
- Step 6Download for geocoding or dialling — Download
regex-extracted.xlsx. The clean postcode column is ready for a geocoder; the phone column is ready for CRM import or a dialler.
Tested UK extraction patterns
Capture-group patterns for the common UK formats. These match the standard cases; obscure formats are noted in edge cases below.
| Target | Example | Pattern (capture group) |
|---|---|---|
| UK postcode (upper-case) | SW1A 2AA | ([A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}) |
| UK postcode (any case) | sw1a 2aa | ([A-Za-z]{1,2}[0-9][0-9A-Za-z]?\s?[0-9][A-Za-z]{2}) |
| UK landline / mobile (0-prefix) | 0207 946 0018 | (0[\d\s-]{9,12}) |
| International +44 | +44 20 7946 0018 | (\+44[\s\d-]{9,12}) |
| Either UK form | 07700 900461 or +447700900461 | (\+44[\s\d-]{9,12}|0[\d\s-]{9,12}) |
What gets returned per cell
First capture group, first match only, empty string if nothing matches.
| Source cell | Pattern | Output |
|---|---|---|
10 Downing St, London SW1A 2AA | postcode (upper) | SW1A 2AA |
flat in london sw1a 2aa | postcode (upper) | `` (empty — lower-case) |
flat in london sw1a 2aa | postcode (any case) | sw1a 2aa |
call 0207 946 0018 or 0788 555 1234 | phone | 0207 946 0018 (first only) |
no address on file | postcode | `` (empty) |
Tier limits
Pro-tier feature; per-file limits.
| Plan | Runs? | Max size | Max rows |
|---|---|---|---|
| Free | No | 5 MB | 10,000 |
| Pro | Yes | 50 MB | 100,000 |
| Pro + Media | Yes | 200 MB | 500,000 |
| Developer | Yes | 500 MB | Unlimited |
Cookbook
Patterns for the address and contact fields you'll actually parse. Because matching is case-sensitive and only the first match per cell is kept, pick the case-aware variant when your data is mixed and plan two passes for postcode + phone.
Postcode from a full address
Pull the postcode off the end of an address line. The capture group leaves the street and town behind.
Source cell: "10 Downing Street, London, SW1A 2AA"
Pattern: ([A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2})
Output: SW1A 2AACase-insensitive postcode
Lists with lower-case entries need a case-aware class — the default tool has no i flag.
Source cell: "order ships to bs1 5tr next week"
Pattern: ([A-Za-z]{1,2}[0-9][0-9A-Za-z]?\s?[0-9][A-Za-z]{2})
Output: bs1 5trUK phone in either format
An alternation matches both the +44 and 0-prefix forms; the first match per cell is returned.
Source cell: "reach us on +44 20 7946 0018"
Pattern: (\+44[\s\d-]{9,12}|0[\d\s-]{9,12})
Output: +44 20 7946 0018First of two phone numbers
When a note lists landline and mobile, only the first is captured. Run again or split the cell for the second.
Source cell: "office 0207 946 0018, mobile 0788 555 1234"
Pattern: (0[\d\s-]{9,12})
Output: 0207 946 0018Flag addresses with no postcode
Rows without a postcode come back empty — sort the column to find addresses that need manual completion.
Source cell: "PO Box 12, Springfield"
Pattern: ([A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2})
Output: (blank)Edge cases and what actually happens
Free plan
Pro requiredThe extractor throws Regex Extractor requires Pro tier. on Free before any parsing.
Lower-case postcodes vs upper-case pattern
MissedMatching is case-sensitive. An [A-Z]-only postcode pattern silently skips sw1a 2aa. Use [A-Za-z] ranges or an inline (?i) for mixed-case lists.
Two phone numbers in a cell
First onlyOnly the first match per cell is returned. A note with landline and mobile yields the first. Run a second pass or split the cell.
Crown dependency / BFPO postcodes
May missGIR 0AA, BFPO, and some overseas-territory codes don't fit the standard pattern. Add specific alternations (e.g. GIR 0AA) if your data includes them.
Phone stored as a number
Leading zero riskCells are read as displayed text; if Excel stored a UK number as a number, it likely dropped the leading 0 before upload, so 0207... may already be 207.... Store phones as text in the source sheet.
Wrong source column header
Empty columnA case-sensitive header mismatch reads every cell empty and produces a silent all-blank output column.
Invalid regex
ErrorAn unbalanced class or group throws a SyntaxError shown as a processing error. Test patterns before running.
Output column collides with a header
OverwritesNaming the output the same as an existing column overwrites it. Use postcode or phone.
Postcode with no space
Handle with \s?Entries like SW1A2AA need the optional space \s? in the pattern, which the recommended pattern includes, to match both SW1A 2AA and SW1A2AA.
Address data on another sheet
IgnoredOnly the first sheet is processed. Move the addresses to sheet 1 before uploading.
Frequently asked questions
What regex extracts a UK postcode?
Use ([A-Z]{1,2}[0-9][0-9A-Z]?\s?[0-9][A-Z]{2}) for upper-case data, or the [A-Za-z] variant for mixed case. The capture group keeps only the postcode.
Does the postcode pattern handle every UK format?
It covers standard residential and commercial formats. Crown dependencies (GIR 0AA), BFPO, and some overseas codes need extra alternations added to the pattern.
How do I extract a UK phone number?
Use (\+44[\s\d-]{9,12}|0[\d\s-]{9,12}) to match both the +44 and 0-prefix forms. Only the first number per cell is returned.
Can I extract both postcode and phone in one run?
No — one pattern per run. Run the tool twice on the result file: once for postcode, once for phone, to add both columns.
Why are my lower-case postcodes blank?
The match is case-sensitive and an [A-Z]-only pattern skips lower-case. Switch to [A-Za-z] ranges or add an inline (?i).
What about cells with no postcode?
They write an empty output cell. Use the change count and sort the column to find addresses needing manual completion.
Is my address data uploaded?
No. SheetJS parses and matches entirely in the browser; nothing reaches a server.
Why did my phone number lose its leading zero?
If the source sheet stored the number as a numeric value, Excel dropped the 0 before you uploaded. Format the phone column as text in the source first.
Does it change my original address column?
No. The source is preserved; the extracted value goes into a new column (default extracted).
What format is the output?
A single-sheet .xlsx named regex-extracted.xlsx, generated in your browser from your XLSX or CSV upload.
What are the size and row limits?
Pro 50 MB / 100,000 rows, Pro + Media 200 MB / 500,000, Developer 500 MB / unlimited. Not available on Free.
How do I split the cleaned list by region after extraction?
Run the output through the conditional splitter to break rows into one sheet per region or area code value.
Privacy first
Every JAD Excel tool runs entirely in your browser using SheetJS and ExcelJS. Your spreadsheets, formulas, and data never leave your device — verified by zero outbound network requests during processing.