
Excel TEXTSPLIT, TEXTBEFORE, and TEXTAFTER: 25 Practical Recipes for Extracting Phone Numbers, Emails, and SKUs
Verification standard: Based on the latest Excel 365 functions. The examples were reproduced directly, and AI tools were used as an aid in organizing the draft.
Related guides (7 internal links)
1) Cheat Sheet (Basic Syntax)
// TEXTSPLIT(text, col_delimiter, [row_delimiter], [ignore_empty], [match_mode], [pad_with])
=TEXTSPLIT(A2, ", ")
// TEXTBEFORE/AFTER(text, delimiter, [instance_num], [match_mode], [match_end], [if_not_found])
=TEXTBEFORE(A2, "-") // Before the first '-'
=TEXTAFTER(A2, "-", 2) // After the second '-'
=TEXTAFTER(A2, {"-","/"}) // After the first match among multiple delimiters
2) 25 Pattern-Based Recipes (Ready to Copy and Paste)
① Split a Name and Email Address
=TEXTBEFORE(A2, " <") // Name
=TEXTBETWEEN(A2, "<", ">") // Email address (in angle brackets)
② Email Username, Domain, and Top-Level Domain
=TEXTBEFORE(A2, "@")
=TEXTAFTER(A2, "@")
=TEXTAFTER(TEXTAFTER(A2, "@"), ".")
③ Keep Only Digits from a Phone Number
=LET(t,A2, d,SEQUENCE(LEN(t)),
TEXTJOIN("",,IF(ISNUMBER(--MID(t,d,1)), MID(t,d,1), "")))
④ Extract a 5-Digit ZIP Code from a Sentence
=TEXTAFTER(TEXTBEFORE(A2," ",-1)," ",-1) // Between the last two spaces
⑤ SKU: First 3 Characters, Number, and Option
=TEXTBEFORE(A2,"-") // Prefix
=TEXTBETWEEN(A2,"-","-") // Number
=TEXTAFTER(A2,"-",2) // Option
⑥ Use Multiple Delimiters at Once
=TEXTSPLIT(A2, {", "," | ","/"," · "})
⑦ Extract the nth Item
=INDEX(TEXTSPLIT(A2,", "), 1, 3) // Third item
⑧ Trim Both Sides and Remove Nonprinting Characters
=TRIM(SUBSTITUTE(A2,CHAR(160)," "))
⑨ Remove the Option in Parentheses from a Product Name
=TEXTBEFORE(A2, " (")
⑩ Keep Only the Root Domain (Excluding Subdomains)
=LET(d,TEXTAFTER(A2,"@"), TEXTAFTER(d,".",-1)&"."&TEXTAFTER(d,".",-2))
⑪ Split Hashtags
=FILTER(TEXTSPLIT(A2," "), LEFT(TEXTSPLIT(A2," "),1)="#")
⑫ City, District, and Neighborhood from an Address
=TEXTBEFORE(A2,"구")+ "구" & " " & TEXTBETWEEN(A2,"구 ","동")+ "동"
⑬ CSV in One Cell to a Table
=TEXTSPLIT(A2, ",", CHAR(10), 1) // Split rows by line break
⑭ Last Word in a Sentence
=TEXTAFTER(A2," ",-1)
⑮ Remove Unneeded Prefixes and Suffixes
=TEXTAFTER(A2, "SKU: ")
=TEXTBEFORE(A2, " - end")
⑯ Convert a Price String to a Number
=--SUBSTITUTE(SUBSTITUTE(A2,",",""),"₩","")
⑰ Extract the Value from a Label: Value Pair
=TEXTAFTER(A2, ": ")
⑱ Combine Multiple Rows into a Sentence
=TEXTJOIN(", ",,A2:A10)
⑲ Keep Only English Letters and Numbers from an Unstructured String
=LET(t,A2, s,SEQUENCE(LEN(t)),
TEXTJOIN("",,IF(OR(CODE(MID(t,s,1))={45,95}),MID(t,s,1),
IF(ISNUMBER(--MID(t,s,1)),MID(t,s,1),
IF((CODE(MID(t,s,1))>=65)*(CODE(MID(t,s,1))<=122),MID(t,s,1),"")))))
⑳ Standardize Date Text
=DATEVALUE(TEXTAFTER(A2," ",-1))
㉑ Spill Labels and Values into Two Columns
=TEXTSPLIT(A2, ": ", CHAR(10))
㉒ Remove the Header and Footer to Keep Only the Body
=TEXTBETWEEN(A2,"---START---","---END---")
㉓ Extract a Parameter Value from a URL
=TEXTAFTER(TEXTBEFORE(A2,"&",-1),"id=")
㉔ Split a Product Name and Specification
=TEXTSPLIT(A2," ",,1) // Ignore consecutive spaces
㉕ Create a Unique List After Splitting
=SORT(UNIQUE(TOCOL(TEXTSPLIT(A2:A,", "),1)))
3) Pre-Cleaning (Spaces and Nonprinting Characters)
- Nonbreaking spaces (CHAR(160)) → standardize them with
SUBSTITUTE - Multiple spaces → set ignore_empty=1 in
TEXTSPLIT - Standardize capitalization →
UPPER/LOWER/PROPER
4) Combine with FILTER, UNIQUE, and XLOOKUP
// Sort unique hashtags
=SORT(UNIQUE(TOCOL(FILTER(TEXTSPLIT(A2:A," "),
LEFT(TEXTSPLIT(A2:A," "),1)="#"),1)))
// Customer count by email domain
=LET(d, TEXTAFTER(B2:B,"@"), SORT(BYROW(UNIQUE(d), LAMBDA(x, COUNTIF(d,x))),2,-1))
5) Error and Performance Checklist
- #VALUE! — Delimiter mismatch → use
IFERRORto set a default value - Large datasets → preprocess with Power Query before applying TEXT* functions
- For spill references, use
=A2#to safely reference the range
6) Practice Tasks and Templates
Task A — Split “Product Name (Color/Size)” in Bulk
=LET(x,TEXTBETWEEN(A2,"(",")"), HSTACK(TEXTBEFORE(A2," ("), TEXTBEFORE(x,"/"), TEXTAFTER(x,"/")))
Task B — Automatically Extract Emails and Phone Numbers from Customer Notes
// Email
=FILTER(A2:A, ISNUMBER(SEARCH("@",A2:A)))
// Phone number (at least 9 digits only)
=FILTER(A2:A, LEN(LET(t,A2:A, TEXTJOIN("",,IF(ISNUMBER(--MID(t,SEQUENCE(LEN(t)),1)),MID(t,SEQUENCE(LEN(t)),1),""))))>=9)
Bookmark this article, then continue to “Advanced LEFT/RIGHT/MID & FIND/SEARCH Combos” to complete your text-processing pipeline.