Tips & tricks · AI · Everywhere · ~15 min per expression · 2 min read
Regex Without the Learning Curve: AI Writes It, Explains It, Tests It
Last reviewed:

Regular expressions are the most powerful tool there is for bulk text editing — find every phone number, pull out email addresses, reformat a thousand lines at once. And they also have the most off-putting syntax in all of tech: the notation looks like spilled alphabet soup, and even people who know regex write it by trial and error. AI flips that equation: you describe in plain words what you're looking for, and you get back an expression, a part-by-part explanation, and a test set — so you don't have to trust it blindly.
How to do it
- Describe what you're looking for, where you'll use it, and add a few sample data points — the samples matter more than a perfect description:
Write me a regular expression for [Google Sheets, the
REGEXEXTRACT function / VS Code / Python].
I want to pull out of the text: [US phone numbers — ten
digits, may have spaces or dashes grouped, and may have
a +1 prefix].
Examples it SHOULD match:
+1 601 123 4567
6011234567
601-123-4567
Examples it should NOT match:
123456 (an order number)
1/6/2026
Return: 1) the expression, 2) a line-by-line explanation
of each part, 3) a table of my examples with the result
match/no match.
- Check the test table — that's the whole trick. You don't need to understand the expression, just see that it does what it should on your examples.
- Try it on a small sample of data first, only then on everything. For replacements, also ask for a generated replacement pattern ("rewrite to format +1 XXX-XXX-XXXX").
- When the expression fails on real data, feed back the specific case: "it didn't match this: [example]" — the fix is one round-trip.
A typical scenario
Freelancer Týna got a thousand-row export from a client, with addresses, phone numbers, and notes all mashed into one column, and needs to turn it into a usable table. By hand it would be an afternoon. Sheets has REGEXEXTRACT, but Týna has never written a regex in her life.
She describes the task with five sample rows, gets back two expressions — for phone numbers and zip codes — with a test table where everything checks out. She drops them into formulas, verifies the result on ten sample rows, and runs it on the whole column. An afternoon of work shrinks to twenty minutes, and now she knows "pull a pattern out of text" is a solved category of problem.
What you get out of it
Bulk text editing that used to be programmers-only — no syntax to learn, but control stays in your hands: the test table is your proof the expression works, and the part-by-part explanation teaches you regex along the way. For developers, the trick saves a round trip to a regex-testing website; for everyone else it unlocks REGEXEXTRACT in Sheets and find-and-replace in editors. For bigger file transformations, there's a follow-on guide: small scripts without programming.
Want to go deeper? The handbook has a whole chapter on it — AI and automation.
Similar tips
Mouse sensitivity: across two monitors with one flick of the wrist
Default pointer and scroll-wheel speed is tuned for monitors from a decade ago. Two sliders save hundreds of arm movements a day.
Set up your chair in a minute: elbows, knees, feet
Most people sit in their chair exactly as it arrived from the store. Three checkpoints — elbows at desk height, knees at a right angle, feet on the floor — take a minute to fix.
Noise-cancelling headphones: focus and a signal, both at once
ANC headphones solve two problems at once: ambient noise, and coworkers who can't tell you don't want to be disturbed.
Was this helpful?
Liked this tip?
I send one like it every week by email. Two minutes to read, hours saved.
The Top 30 tips e-book, free — it lands in your inbox right away.
Then 1 tip a week · no spam · unsubscribe in one click
Prefer a system to single tips? The free email course — seven days, seven emails, one skill a day.