Sub topic 1
Text, delimiters, and what these functions do
Prerequisites
This chapter assumes you can:
- Enter a formula in Google Sheets and refer to cells and ranges such as
A2andA2:A10. - Write text values in double quotes inside a formula, as in
"hello". - Use functions that take arguments, such as
TRIMandIFERROR.
You don't need to know regular expressions yet. Later chapters cover them step by step. This chapter sets up the vocabulary and the mental model for the rest of the tutorial.
Why text cleaning needs its own tools
Data often arrives as one cell that holds several facts. A contact export might hold Ada Lovelace, Mathematician; London in a single cell. A tag column might hold red,green,blue. An order note might hold Refund for ORD-10492 issued. Sorting, filtering, counting, and charting all work better when each fact sits in its own cell, or when a list of facts is rebuilt into one tidy string.
Three functions handle most of this work:
| Function | What it does | Direction |
|---|---|---|
| `SPLIT` | Cuts one text value into several pieces at a delimiter | One cell to many cells |
| `JOIN` | Glues many values into one text value with a delimiter between them | Many cells to one cell |
| `REGEXEXTRACT` | Returns the part of a text value that matches a pattern | One cell to the matching part |
SPLIT and JOIN are inverse operations. Both depend on a delimiter. REGEXEXTRACT is different. It finds text by its shape, such as "one or more digits", instead of by a separator character.
Text values in Sheets
Every cell value in Sheets has a type. The types that matter here are text (also called a string), number, date, and boolean. A string is a sequence of characters, and that includes digits, spaces, and punctuation.
The type controls how a value behaves:
- Text is left-aligned by default. Numbers are right-aligned by default.
SUMignores text."42"stored as text adds nothing to a total.- Text comparison and numeric comparison give different answers. As text,
"10"sorts before"9". As numbers, 9 comes before 10.
You can check a type with ISTEXT and ISNUMBER:
=ISTEXT(A2)
=ISNUMBER(A2)Each returns TRUE or FALSE. These two checks are the quickest way to diagnose a column that "looks right but won't add up". The cause is usually numbers stored as text. You will meet this again when REGEXEXTRACT returns digits as text.
Text inside formulas
A literal string in a formula is wrapped in double quotes: "," is a string holding one comma. A string with nothing between the quotes, "", is the empty string. It has length zero and is not the same as a blank cell, although many functions treat the two alike.
To put a double quote inside a string, double it:
="She said ""hello"""This returns She said "hello". The outer quotes mark the start and end. Each "" inside stands for one literal quote. Later chapters on regular expressions will use this rule, because patterns are also written as strings.
Regional settings change the separator
The examples in this tutorial use a comma between function arguments, as in SPLIT(A2, ","). Spreadsheets set to some locales, such as many European ones, use a semicolon instead: SPLIT(A2; ","). If a formula that looks correct gives a parse error, check the locale under File > Settings. Only the argument separator changes. The text delimiters inside quotes stay the same.
What a delimiter is
A delimiter is a character or sequence of characters that marks the boundary between pieces of data. In red,green,blue the comma is the delimiter, and the pieces are red, green, and blue.
Common delimiters:
| Delimiter | Typical use | Column |
|---|---|---|
| Comma `,` | Tags, CSV-style lists | |
| Semicolon `;` | Lists whose items contain commas | |
| Pipe `\ | ` | Exports that avoid commas and semicolons |
| Space | Words in names and sentences | |
| Slash `/` | Paths, dates such as `2026/11/27` | |
| Comma plus space `, ` | Human-written lists | |
| Newline | Multi-line cell content |
Two properties of delimiters cause most of the trouble in practice.
A delimiter can be more than one character. , (comma then space) is a single delimiter of two characters. SPLIT can treat it as one unit or as two separate characters. The choice changes the result. The next chapters show how to control it with the split_by_each argument.
A delimiter that appears twice in a row creates an empty piece. In red,,blue there is nothing between the two commas. Whether that empty piece survives in the output is another option you control, remove_empty_text.
The three functions at a glance
This section shows the shape of each function. Later chapters cover the details and edge cases.
SPLIT
=SPLIT(A2, ",")With red,green,blue in A2, this formula in B2 puts red in B2, green in C2, and blue in D2. One formula fills several cells. That behavior is called spilling, and the cells it fills must be empty.
The full signature has four arguments: SPLIT(text, delimiter, [split_by_each], [remove_empty_text]). The last two are optional.
JOIN
=JOIN(", ", A2:A4)If A2:A4 holds red, green, and blue, this returns the single string red, green, blue. The delimiter comes first and the values come after it. This is the reverse of SPLIT, where the text comes first. That reversal trips up many people, so check the order whenever a result looks wrong.
REGEXEXTRACT
=REGEXEXTRACT(A2, "\d+")With Refund for ORD-10492 issued in A2, this returns 10492, the first run of one or more digits. No delimiter is involved. The pattern describes what to look for, and the function returns the first match. Sheets uses the RE2 regular expression syntax, which the regex chapter introduces.
How the functions fit together
Real cleaning jobs chain these steps. A typical sequence is:
- Split a messy cell into pieces.
- Trim stray spaces from each piece.
- Drop empty pieces.
- Join what remains with a clean delimiter.
Or you use REGEXEXTRACT to isolate an ID, then convert it to a number. The final chapters of this tutorial work through those combinations. Each one is built from the single-function behavior covered first.
Spotting the delimiter in your data
Before writing a formula, find out what actually separates the pieces. Data that looks like it uses a plain space or comma sometimes uses something else. Three checks help.
Measure the cell. LEN returns the number of characters:
=LEN(A2)If a cell that shows red,green,blue has length 14 and you count 14 visible characters, nothing is hidden. If LEN returns more than you can see, the cell has extra characters, often spaces at either end.
Identify one character. CODE returns the numeric code of the first character of a string. Combine it with MID to inspect any position:
=CODE(MID(A2, 4, 1))This returns the code of the fourth character. A regular space gives 32. A non-breaking space gives 160. Web pages and copied emails often contain non-breaking spaces. They look like spaces but are a different character, so TRIM does not remove them and a space delimiter in SPLIT does not match them.
Normalize before you split. If you find non-breaking spaces, replace them with regular spaces first:
=SUBSTITUTE(A2, CHAR(160), " ")CHAR(160) produces the non-breaking space. The result is a string that TRIM and SPLIT handle as expected.
Choosing between delimiter-based and pattern-based tools
Use SPLIT when the data has a consistent separator and you want every piece. Use REGEXEXTRACT when you want one specific part and the surrounding text varies.
| Situation | Better tool | Why |
|---|---|---|
| `red,green,blue` into three cells | `SPLIT` | Every piece is wanted, and the delimiter is consistent |
| An order ID inside free-text notes | `REGEXEXTRACT` | The ID's position varies, but its shape is fixed |
| A list in cells that must become one string | `JOIN` | It is the inverse of `SPLIT` |
| `Last, First` into two columns | `SPLIT` with `", "` | Fixed two-part structure |
| An email address inside a paragraph | `REGEXEXTRACT` | No delimiter marks where the address starts or ends |
Some jobs can be done either way. When a delimiter is reliable, SPLIT is easier to read and maintain. Regular expressions are more flexible but harder to debug, so choose them when a delimiter can't solve the problem.
A worked example
Suppose column A holds contact notes in this form:
| Row | A (raw note) |
|---|---|
| 2 | `Ada Lovelace, Mathematician; London` |
| 3 | `Grace Hopper, Admiral; New York` |
Each cell uses a comma between name and role, and a semicolon before the city. To plan the cleanup, ask four questions in order.
- What are the delimiters? A comma and a semicolon, with a space after each.
- Do I want every piece? Yes, so
SPLITfits. - Will stray spaces remain? Yes, after splitting on
,and;each piece after the first begins with a space, so trimming is needed. - Does the output need to be one string again? Not here. Three columns are enough.
Splitting on both characters at once is a topic for the next chapters. For now, check each assumption with a quick test. This formula tells you whether the first note has the expected characters:
=LEN(A2) - LEN(SUBSTITUTE(A2, ";", ""))It returns how many semicolons the cell contains. It removes every semicolon, measures the shorter string, and subtracts that length from the original. For A2 above, the answer is 1. If any row returns 0 or 2, that row will not split like the others, and you have found a data problem before it spoiled your output.
What comes next
The following chapters take each function in turn. SPLIT comes first, then its options, then how its results spill across cells and how to apply it to a whole column. JOIN follows, including ranges and skipping blanks. After a short introduction to regular expressions, REGEXEXTRACT is covered with capture groups, error handling, and number conversion. The last chapters combine all three and list the most common pitfalls.
Exercise
Cell A2 holds the text a;b;;c. You plan to split it on ;. How many semicolons does the cell contain, which formula counts them, and what is unusual about the data that you should plan for?
Show answer
The cell contains three semicolons. The formula =LEN(A2) - LEN(SUBSTITUTE(A2, ";", "")) returns 3, because removing the semicolons shortens the string from 6 characters to 3. The unusual part is the two semicolons in a row, which have nothing between them. That produces an empty piece between b and c, so you must decide whether to keep or drop empty pieces. That decision is controlled by the remove_empty_text argument of SPLIT.
Exercise
A cell shows New York but =SPLIT(A2, " ") returns a single cell, New York, and =LEN(A2) returns 8. What is the likely cause, which formula would you use to confirm it, and how would you fix it?
Show answer
The gap is probably a non-breaking space (character code 160), not a regular space (code 32), so the space delimiter does not match it. Confirm with =CODE(MID(A2, 4, 1)), which returns 160 if this is the cause. Fix it by normalizing first: =SPLIT(SUBSTITUTE(A2, CHAR(160), " "), " ").