Thanks for the suggestion. Managed to get it working with:
^[a-zA-Z]{1,2}[0-9]{1,2}.?(?:[0-9]|zero|one|two|three|four|five|six|seven|eight|nine).[a-zA-Z]{2}$
Very similar to yours but tweaked slightly.
I still had to use some conversion afterwards to replace the 'four' to '4' and remove unnecessary spaces but at least it now passes validation.
------------------------------
Tim Speakman
Tech Support Engineer
------------------------------
Original Message:
Sent: 02-19-2026 07:39
From: Cameron Tomlin
Subject: UK Postcode regex
Hello Tim,
The issues is that speech to text analytics transcripts 4 as four. Your regex pattern needs to accept both numeric digits and their word equivalents.
Option A - Simple for single digits
^[a-zA-Z]{1,2}d{1,2}s?(zero|one|two|three|four|five|six|seven|eight|nine|d)s?[a-zA-Z]{2}$
Option B - More comprehensive UK post code regex with case insensitivity
(?i)^[a-z]{1,2}[0-9]{1,2}s?([0-9]|zero|one|two|three|four|five|six|seven|eight|nine|ten)s?[a-z]{2}$
Cheers,
------------------------------
Cameron
Online Community Manager/Moderator
Original Message:
Sent: 02-19-2026 04:57
From: Tim Speakman
Subject: UK Postcode regex
I am trying to find the regex to use in a bot flow that validates a UK postcode entered.
Using 'M15 4FN' as an example, when I speak it, the bot hears 'M15 four FN' and passing that through the below regex fails validation.
\b[a-z]{1,2}[0-9]{1,2}[0-9]{1}[a-z]{2}\b
Have tried various AI suggested options but to no avail.
Does anyone have the correct regex we should be using?
#ArchitectandDesign
------------------------------
Tim Speakman
Tech Support Engineer
------------------------------