It’s 3:12 PM on a Tuesday. You just opened the Q2 vendor list from Procurement — 847 rows of inconsistent email domains, phone numbers with mixed parentheses/spaces/dashes, and product codes like 'SKU-2024-AB-7X' buried in notes. Your task: isolate all '@gmail.com' addresses, standardize phone formatting, and pull the last two letters from each SKU. You type REGEXMATCH into cell C2… and get #NAME?. Again.
The Problem
Excel doesn’t support regex in formulas — not in Excel for Microsoft 365, not in Excel 2021, not even in Excel for Mac 16.7. That’s the hard truth. But what most people miss is that Excel *does* have built-in tools that behave like regex when combined correctly — and they’re faster than writing VBA for simple cases.
Here’s a real snippet from that vendor list (A1:E6). Notice the chaos:
| Vendor Name | Contact Email | Phone | SKU Notes | Region |
|---|---|---|---|---|
| Sarah Chen | sarah@acmecorp.io | (555) 123-4567 | Primary SKU: SKU-2024-AB-7X | APAC |
| Miguel Rios | miguel+dev@outlook.com | 555.987.6543 | Backup: SKU-2024-CX-9T | EMEA |
| Priya Kapoor | priya@testmail.gmail.com | +1-555-444-3333 | Legacy SKU: SKU-2023-ZY-2F | NA |
| Dmitri Volkov | dmitri@startup.dev | 555 888 7777 | New SKU: SKU-2024-XY-1L | EMEA |
| Aisha Johnson | aisha@company.co.uk | (555)888-7777 ext. 42 | Test SKU: SKU-2024-QW-5M | NA |
The Solution
You don’t need regex — you need three functions used together: TEXTSPLIT, REGEXREPLACE — wait, no. Scratch that. REGEXREPLACE doesn’t exist. What *does* exist is SUBSTITUTE, SEARCH, LEN, MID, and — crucially — TEXTAFTER and TEXTBEFORE (introduced in 2022). They’re your regex proxies.
Let’s fix the email domain extraction first. Goal: pull everything after the last @, but only if it ends in .gmail.com.
- Step 1: In F2, use
=TEXTAFTER(B2,"@")→ returnsacmecorp.iofor Sarah - Step 2: In G2, check if it ends with
.gmail.com:=IF(ISNUMBER(SEARCH(".gmail.com",F2)),F2,"") - Step 3: Standardize phone numbers. In H2, paste this single formula:
=SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B2,"(",""),")",""),"-",""),".","")," ","")
Then wrap it inTEXT:=TEXT(H2,"(000) 000-0000")— but only if length = 10. So full version:=IF(LEN(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B2,"(",""),")",""),"-",""),".","")," ",""))=10,TEXT(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B2,"(",""),")",""),"-",""),".","")," ",""),"(000) 000-0000"),B2) - Step 4: Extract last two letters before the final dash in SKU. In I2:
=RIGHT(TEXTBEFORE(D2,"-",-1),2)— yes,TEXTBEFOREsupports negative instance counts. This pulls7X,9T, etc., reliably.
Here’s the cleaned output (F1:I6):
| Domain | Is Gmail | Clean Phone | SKU Code |
|---|---|---|---|
| acmecorp.io | (555) 123-4567 | 7X | |
| outlook.com | (555) 987-6543 | 9T | |
| testmail.gmail.com | testmail.gmail.com | (555) 444-3333 | 2F |
| startup.dev | (555) 888-7777 | 1L | |
| company.co.uk | (555) 888-7777 | 5M |
Going Further
You *can* simulate basic regex with LAMBDA. Try this reusable function in Name Manager (Formulas > Name Manager > New):
Name: ExtractPattern
Refers to:=LAMBDA(text,pattern,LET(pos,SEARCH(pattern,text),IF(ISERROR(pos),"",MID(text,pos,LEN(pattern)))))
Then use =ExtractPattern(D2,"SKU-2024-") to grab the prefix. Not full regex — but enough to avoid repeating SEARCH/MID combos.
For true pattern matching on Windows, enable Power Query. Go to Data > Get Data > From Other Sources > Blank Query. Paste this in Advanced Editor:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Added Custom" = Table.AddColumn(Source, "Domain", each Text.AfterDelimiter([Contact Email], "@")),
#"Filtered Rows" = Table.SelectRows(#"Added Custom", each Text.EndsWith([Domain], ".gmail.com"))
in
#"Filtered Rows"
This *is* regex-adjacent — Power Query uses .NET regex syntax, so Text.Matches([Domain], ".*gmail\.com") works.
Surprising tip: FIND is case-sensitive. SEARCH is not. Use FIND when you need to distinguish 'GMAIL.COM' from 'gmail.com' — no regex required.
When NOT to Use This
- If you need lookbehind/lookahead (e.g., “match ‘USD’ only if preceded by a number”), skip Excel formulas entirely. Use Power Query or Python + xlwings.
- If your data has nested delimiters — like
"{name:"John",email:"j@x.com"}"— TEXTSPLIT will break. Use Power Query’s JSON parser instead. - If you’re on Excel for Mac before version 16.82:
TEXTAFTERandTEXTBEFOREdon’t exist. Fall back toMID/SEARCHcombos — slower, but functional. - If you’re validating email structure (e.g., “must have one @, no spaces, valid TLD”), Excel can’t do that safely. Use an external API or web-based validator.
Keyboard Shortcuts
| Action | Shortcut | Notes |
|---|---|---|
| Open Name Manager | Ctrl + F3 | Essential for managing LAMBDA functions |
| Open Power Query Editor | Alt + D, P | Windows only. Press Alt+D, release, then P |
| Toggle formula view | Ctrl + ` | Backtick key, left of 1. See all formulas at once |
| Fill down selected cells | Ctrl + D | After typing a formula in top cell, select range, then Ctrl+D |