
Master Text Analysis with LEN, FIND, and SEARCH (Positions, Counts, and Nth Occurrences in 1 Minute)
Extract only the domain from an email address, only the extension from a file name, or even the position of the Nth delimiter in a product code—combining LEN, FIND, and SEARCH can do it all.
Core Concepts and Differences
| Function | Syntax | Key Feature |
|---|---|---|
| LEN | =LEN(text) | Returns the number of characters, including spaces |
| FIND | =FIND(find_text, within_text, [start_num]) | Case-sensitive; does not support wildcards |
| SEARCH | =SEARCH(find_text, within_text, [start_num]) | Case-insensitive; supports * ? wildcards |
Count Length – LEN
Example 1) Length Including Spaces
=LEN(A2)
Example 2) Excluding Leading and Trailing Spaces
=LEN(TRIM(A2))
TIP: NBSP (CHAR(160)) may not be removed by TRIM. For an accurate result, replace it first with SUBSTITUTE(A2,CHAR(160)," "), then use LEN.
Find a Position – FIND vs. SEARCH
Example 3) Position of @ in an Email Address
=FIND("@", A2)
Example 4) Case-Insensitive Check for Included Text
=ISNUMBER(SEARCH("kim", A2)) // Returns TRUE if included
Example 5) Wildcards
=ISNUMBER(SEARCH("*.xlsx", A2)) // File name with a .xlsx extension
Nth Occurrence Position and Last Delimiter
Example 6) Position of the Nth Hyphen
=FIND("#", SUBSTITUTE(A2, "-", "#", N))
If there are fewer than N delimiters, an error occurs → handle it with IFERROR:
=IFERROR(FIND("#",SUBSTITUTE(A2,"-","#",N)),0)
Example 7) Position of the Last Delimiter
=FIND("|", SUBSTITUTE(A2,"-","|", LEN(A2)-LEN(SUBSTITUTE(A2,"-",""))))
Example 8) Simple Microsoft 365 Version (Find from the End)
=TEXTAFTER(A2,"-", -1) // Text after the last '-'
=TEXTBEFORE(A2,"-", -1) // Text before the last '-'
Count Occurrences
Example 9) Number of Occurrences of a Specific Character or Text String
=(LEN(A2)-LEN(SUBSTITUTE(A2, "ab", "")))/LEN("ab")
Case-insensitive:
=(LEN(UPPER(A2))-LEN(SUBSTITUTE(UPPER(A2),"AB","")))/2
Extract the Part You Need (LEFT/MID/RIGHT · TEXTAFTER/TEXTBEFORE)
Example 10) Email Domain
=RIGHT(A2, LEN(A2)-FIND("@",A2))
/* 365 */ =TEXTAFTER(A2,"@")
Example 11) Extension (After the .)
=RIGHT(A2, LEN(A2)-FIND("|",SUBSTITUTE(A2,".","|",LEN(A2)-LEN(SUBSTITUTE(A2,".","")))))
/* 365 */ =TEXTAFTER(A2,".",-1)
Example 12) Middle Code (Between Two Hyphens)
=MID(A2, FIND("-",A2)+1, FIND("-",A2,FIND("-",A2)+1)-FIND("-",A2)-1)
/* 365 */ =TEXTSPLIT(A2,"-")(1,2)
Common Mistakes and Performance Tips
- #VALUE! error → The text you are looking for may not exist, so wrap the formula in
IFERRORor provide a default value. - NBSP/line breaks → Clean them with
SUBSTITUTE(,CHAR(160)," ")andSUBSTITUTE(,CHAR(10)," ")before searching. - Performance → Reuse repeated calculations such as
LEN(A2)withLET, and avoid whole-column references (X:X). - Case sensitivity → Use FIND for strict matching and SEARCH for flexible matching.
Summary
| Goal | Common Formula |
|---|---|
| Length | LEN(A2), or LEN(TRIM(...)) after cleaning spaces |
| Check for included text | ISNUMBER(SEARCH("keyword",A2)) |
| Nth position | FIND("#",SUBSTITUTE(A2,"-","#",N)) |
| Text after the last delimiter | TEXTAFTER(A2,"-",-1) or a SUBSTITUTE-based formula |
FAQ
Why does FIND return an error when it cannot find the text?
Because it returns a position (a number), it returns #VALUE! when the text is not found. Provide a default value, such as IFERROR(FIND(...),0).
Is LEN accurate for strings containing both Korean and English characters?
Yes, LEN returns the number of characters. Use LENB only when you need a byte-based calculation.