What Most People Miss About Does Excel Support Regex

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 NameContact EmailPhoneSKU NotesRegion
Sarah Chensarah@acmecorp.io(555) 123-4567Primary SKU: SKU-2024-AB-7XAPAC
Miguel Riosmiguel+dev@outlook.com555.987.6543Backup: SKU-2024-CX-9TEMEA
Priya Kapoorpriya@testmail.gmail.com+1-555-444-3333Legacy SKU: SKU-2023-ZY-2FNA
Dmitri Volkovdmitri@startup.dev555 888 7777New SKU: SKU-2024-XY-1LEMEA
Aisha Johnsonaisha@company.co.uk(555)888-7777 ext. 42Test SKU: SKU-2024-QW-5MNA

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.

  1. Step 1: In F2, use =TEXTAFTER(B2,"@") → returns acmecorp.io for Sarah
  2. Step 2: In G2, check if it ends with .gmail.com: =IF(ISNUMBER(SEARCH(".gmail.com",F2)),F2,"")
  3. Step 3: Standardize phone numbers. In H2, paste this single formula:
    =SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(B2,"(",""),")",""),"-",""),".","")," ","")
    Then wrap it in TEXT: =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)
  4. Step 4: Extract last two letters before the final dash in SKU. In I2:
    =RIGHT(TEXTBEFORE(D2,"-",-1),2) — yes, TEXTBEFORE supports negative instance counts. This pulls 7X, 9T, etc., reliably.

Here’s the cleaned output (F1:I6):

DomainIs GmailClean PhoneSKU Code
acmecorp.io(555) 123-45677X
outlook.com(555) 987-65439T
testmail.gmail.comtestmail.gmail.com(555) 444-33332F
startup.dev(555) 888-77771L
company.co.uk(555) 888-77775M

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: TEXTAFTER and TEXTBEFORE don’t exist. Fall back to MID/SEARCH combos — 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

ActionShortcutNotes
Open Name ManagerCtrl + F3Essential for managing LAMBDA functions
Open Power Query EditorAlt + D, PWindows only. Press Alt+D, release, then P
Toggle formula viewCtrl + `Backtick key, left of 1. See all formulas at once
Fill down selected cellsCtrl + DAfter typing a formula in top cell, select range, then Ctrl+D
David Park

David Park

David brings deep expertise in office supply evaluation and procurement. He has tested hundreds of products to help teams make informed purchasing decisions.