For decades, regular expressions—better known as “regex”—have held a reputation somewhere between “useful superpower” and “arcane black magic.” They sit quietly behind the scenes of nearly every digital system the British public interacts with: banking fraud filters, NHS data cleaning scripts, GOV.UK document searches, ticketing systems, newsroom content management tools, and countless university research pipelines.
And yet, for most people—including many well-educated, technologically literate citizens—the very sight of a regex can provoke confusion. A pattern such as:
^[A-Z][a-zA-Z'-]{1,29}$
looks, to many, less like a practical tool and more like the lost scribbles of an esoteric cult.
Enter ChatGPT.
In the past two years, AI-assisted software has begun to demystify this once-intimidating technology. It is helping students, researchers, engineers, journalists, and even curious retirees understand and create regular expressions without needing to memorise unusual symbols or refer endlessly to documentation.
This commentary aims to explain how ChatGPT writes regular expressions, why this matters for the UK public, and how individuals and institutions can use its capabilities safely, thoughtfully, and effectively.

Before we can explore how ChatGPT writes regex, we must explain what they are—preferably in language a typical British reader might use over a cup of tea.
They tell a computer how to recognise specific text—postcodes, phone numbers, names, email addresses, National Insurance Numbers, dates, or anything else with a predictable structure.
For example:
If the DVLA wants to verify a UK vehicle registration, it uses a regex.
If a university researcher cleaning survey data wants to find incorrectly formatted postcodes, they use a regex.
If a journalist scraping local council PDFs wants to extract planning application numbers, they use a regex.
With a single line of text, you can instruct a computer to find:
every British date written as DD/MM/YYYY
every word containing a hyphen but not ending in one
every email sent from a .gov.uk domain
every duplicate entry in a long dataset
A typical UK worker is unlikely to write:
^[A-Z]{2}[0-9]{2}\s?[0-9][A-Z]{2}$
and know instantly that it validates a UK vehicle registration format.
For most people, regular expressions are:
unforgiving
syntactically obscure
easy to get wrong
difficult to read after a few days
challenging to adapt or debug
This is exactly why ChatGPT has become a helpful and widely adopted companion.
ChatGPT acts as a translator: it converts ordinary language descriptions of patterns into precise, functioning regular expressions.
“Write a regex to match UK mobile numbers starting with 07, with or without spaces.”
ChatGPT will respond with something like:
^07\d(?:\s?\d){8}$
But more importantly, it will explain what each part means.
This means even a reader with no technical background can:
learn the structure
adjust the pattern
reuse it confidently
understand mistakes when something does not match
A civil servant might say:
“Find entries where the postcode is missing the space.”
ChatGPT will provide a regex such as:
^[A-Z]{1,2}\d[A-Z\d]?\d[A-Z]{2}$
that matches all valid UK postcodes without the optional space.
A journalist might ask:
“Write a regex that masks all but the last four digits of a phone number.”
ChatGPT can propose:
(?<=\d{2})\d(?=\d{4})
with instructions for replacement.
It removes the main barrier between everyday users and a very useful, historically specialist tool.
The UK is steadily becoming a data-driven society. Public services—from HMRC to the NHS—are increasingly digital, researchers work with enormous datasets, and workplaces expect basic technical fluency.
Regex, though rarely discussed publicly, is a backbone of this digital reality.
ChatGPT makes it accessible at a moment when accessibility matters.
Many UK organisations—universities, councils, small businesses—lack IT specialists. Staff who once had to wait days for technical assistance can now produce working expressions themselves, with explanations.
The result:
fewer delays
lower costs
more confident staff
faster data cleaning and research analysis
British investigative journalism frequently involves extracting hidden details from large documents, emails, or PDF dumps.
Tools powered by regex are indispensable.
Now, ChatGPT lets reporters describe the patterns they seek—“planning references beginning with 23/,” “all email addresses belonging to contractors,” “any lines with a monetary value”—and instantly receive usable expressions.
Whether in computer science, digital humanities, political research, or linguistics, students increasingly work with text datasets. ChatGPT serves as a patient tutor: generating examples, answering questions, and offering step-by-step breakdowns.
The UK has a persistent shortage of skilled data workers. Teaching regex has historically been slow because of its steep learning curve.
ChatGPT removes that obstacle.
ChatGPT identifies what the user wants:
allowed characters
disallowed characters
repetition
position (start/end of line)
optional components
grouping
Depending on context—Python, JavaScript, POSIX, PCRE—ChatGPT chooses the appropriate syntax.
Users can ask ChatGPT:
“Test this regex against sample data.”
“Explain why this pattern fails for these examples.”
“Improve accuracy without matching unintended strings.”
The model can simulate expected matches and point out logical errors.
Every component can be unpacked:
\d is a digit
[A-Z] is any capital letter
{3,5} means repeat three to five times
^ anchors to start
$ anchors to end
This explanatory layer is what makes regex learning finally approachable.
This section provides accessible examples that a British audience might encounter in work, study, or daily digital life.
Plain English prompt:
“Write a regex for NI numbers: two letters, six digits, one final letter.”
ChatGPT output:
^[A-CEGHJ-PR-TW-Z]{2}\d{6}[A-D]$
Prompt:
“Match dates in DD/MM/YYYY format.”
\b\d{2}\/\d{2}\/\d{4}\b
Prompt:
“Find all academic email addresses.”
[A-Za-z0-9._%+-]+@[\w.-]+\.ac\.uk
Prompt:
“Find multiple consecutive spaces.”
\s{2,}
Prompt:
“Match monetary amounts like £1,200.50.”
£\d{1,3}(?:,\d{3})*(?:\.\d{2})?
This kind of immediate translation is transformational.
Instead of memorising syntax, learners focus on the underlying logic of patterns.
ChatGPT encourages experimentation—testing, tweaking, and understanding failure without embarrassment.
Learning becomes conversational: users can ask “Why?” at every step and receive clear, structured explanations.
Because users can generate personalised examples, learning becomes hands-on almost instantly.
While ChatGPT’s regex capabilities are powerful, responsible use is essential.
Anyone working with sensitive UK data—health records, school information, passport IDs—must ensure they do not upload personal information.
Generated regex is accurate—but users should still test it with diverse examples.
ChatGPT enhances understanding, but should not replace foundational literacy. Users benefit most when they learn why patterns work.
Institutions should use ChatGPT to reduce bottlenecks—not remove specialists. Complex data workflows still require human oversight.
Beyond regex, entire search workflows may soon be written using natural language only.
ChatGPT-like tools may routinely prepare datasets for public bodies, charities, and universities.
Expect UK schools and universities to include AI-assisted regex writing in digital literacy modules.
Regex-powered automation could help simplify everything from benefits processing to FOI document classification.
Regular expressions may have once seemed forbidding, but they are now becoming accessible to millions. ChatGPT is not just simplifying a technical skill—it is democratising the ability to interact with digital systems that shape modern British life.
By turning plain English into clear, accurate, well-explained patterns, ChatGPT:
empowers workers
supports researchers
accelerates journalism
improves digital literacy
and strengthens the UK’s capacity to work with data responsibly and efficiently
Regex is no longer a tool reserved for specialists. It is now a skill any motivated person can learn—with an AI tutor at their side.