Text formula page
Extract First Word Formula
Use this when names, labels, or imported text need the first token separated.
Best for
Extract the first word from text.
What it returns
If A2 is Maya Chen, the result is Maya.
Copy formulas
=TEXTBEFORE(TRIM(A2)&" ", " ")=REGEXEXTRACT(TRIM(A2), "^\S+")Excel uses TEXTBEFORE with an appended space so a single word still works. Google Sheets uses REGEXEXTRACT to return the first non-space run.
Example data
| Raw Text | Example Result |
|---|---|
| Maya Chen | Maya |
| SKU-1001-East | SKU |
| https://www.example.com/pricing | example.com |
| Acme North | Acme North |
What it returns
If A2 is Maya Chen, the result is Maya.
How the formula works
- TRIM removes extra spaces before extraction.
- The formula returns text before the first space.
- The Google Sheets version captures the first non-space run.
| Syntax piece | Role in the formula |
|---|---|
| TRIM(A2) | The source text with leading, trailing, and repeated regular spaces normalized. |
| TRIM(A2)&" " | The Excel source with an appended space so a one-word value has a delimiter. |
| " " | The Excel delimiter marking the first word boundary. |
| ^\S+ | The Google Sheets regex for the first non-space run. |
Verified examples
=TEXTBEFORE(TRIM(A2)&" ", " ")Excel: Enter Maya Chen in A2. Returns: Maya
=REGEXEXTRACT(TRIM(A2), "^\S+")Google Sheets: Enter two leading spaces, Acme, three spaces, North, and two trailing spaces in A2. Returns: Acme
=TEXTBEFORE(TRIM(A2)&" ", " ")Excel: Enter SKU-1001-East in A2. Returns: SKU-1001-East
Common errors and fixes
| Issue | Likely cause | Fix |
|---|---|---|
| The first word is not separated | The input contains nonbreaking spaces rather than regular spaces. | Replace CHAR(160) or the imported nonbreaking space before applying TRIM. |
| Punctuation remains in the result | The formulas split on whitespace but do not remove punctuation. | Add a separate cleanup step if punctuation should be stripped. |
| TEXTBEFORE is unavailable | The Excel version predates the TEXTBEFORE function. | Use a legacy LEFT and FIND pattern or the split-text alternative. |
When not to use this formula
- Do not use this pattern when the first token must be punctuation-normalized or parsed as a separate semantic field.
Alternatives
| Alternative | When to use it |
|---|---|
| Split Text Formula | Use when every whitespace-delimited part should be returned or split across cells. |
| Extract Last Word Formula | Use when the final token, rather than the first, is needed. |
Related formulas
Official references
- TEXTBEFORE function from Microsoft
- REGEXEXTRACT function from Google
FAQ
Why does the Excel formula append a space?
The appended space gives TEXTBEFORE a delimiter even when A2 contains only one word.
Does this remove punctuation?
No. Punctuation remains part of the token because the formulas only identify whitespace boundaries.