Sub topic 1
Text, Delimiters, and What These Functions Do
Prerequisites
You should know how to enter formulas and reference cells and ranges in Google Sheets. You should also know that a text value is a string, and that strings appear inside double quotes in formulas. This chapter uses basic functions such as TRIM and IFERROR.
Google Sheets stores text in cells as characters. A value such as Maya Chen, [email protected], Support is one string, even though it contains several pieces of information. Text functions help you separate, combine, or find those pieces.
The functions in this chapter have different jobs:
| Function | Main job | Typical result |
|---|---|---|
| `SPLIT` | Separates one string at a delimiter | Several cells |
| `JOIN` | Combines values with a delimiter | One string |
| `REGEXEXTRACT` | Finds text that matches a pattern | One or more values |
A delimiter is a character or string that marks a boundary between pieces of text. Common delimiters include commas, spaces, semicolons, slashes, and hyphens.
How the Functions Relate
Suppose cell A2 contains this value:
Maya Chen, [email protected], SupportThe commas are delimiters. SPLIT can use them to place each piece in a separate cell:
=SPLIT(A2, ", ")The result spills into neighboring cells:
| A | B | C |
|---|---|---|
| Maya Chen | [email protected] | Support |
A spilled result is a formula result that occupies more than one cell automatically. The cells where the result will appear must be empty.
JOIN performs the reverse operation. If A2:C2 contains the three values above, this formula combines them:
=JOIN(", ", A2:C2)The first argument is the delimiter to insert. The second argument is the range or array of values to combine.
REGEXEXTRACT takes a different approach. It does not need a fixed delimiter. Instead, it searches for text that matches a regular expression, which is a pattern describing text.
For example, this formula finds an email-like substring in A2:
=REGEXEXTRACT(A2, "[\w.+-]+@[\w-]+\.[\w.]+")The pattern means “find one or more characters that can appear before an @, followed by a domain name and a dot.” The function returns the first matching substring.
A Working Model
Think of the three functions as operations on a path:
flowchart TD
A["One text string"] -->|SPLIT at delimiters| B["Several values"]
B -->|JOIN with a delimiter| C["One combined string"]
A -->|REGEXEXTRACT a pattern| D["Matching substring or groups"]The functions can also be combined. For example, you might split a semicolon-separated list, remove extra spaces, and join the cleaned values with commas:
=JOIN(", ", ARRAYFORMULA(TRIM(SPLIT(A2, ";"))))Here, SPLIT creates several values. TRIM removes extra spaces around each value. ARRAYFORMULA applies TRIM to every value in the resulting array. JOIN combines the cleaned values.
Delimiters Are Data
A delimiter is part of the input text, so choose one that matches the data. Splitting on a comma works only when commas consistently separate fields. If a field can contain commas, a simple split may produce the wrong columns.
For example, splitting Chen, Maya, Support at every comma creates three pieces, even if the intended name is Chen, Maya. In that case, use a more reliable source format or a pattern that identifies the exact part you need.
> callout note > Check the actual characters in your data. A comma followed by a space and a comma without a space are different delimiter choices.
Choosing a Function
Use SPLIT when the boundaries are known and repeated. Use JOIN when you already have separate values and need one readable string. Use REGEXEXTRACT when the text has a recognizable pattern, such as an email address, an order ID, or a sequence of digits.
Exercise
Which function should you use to turn red; blue; green into separate cells, and which delimiter should you provide?
Show answer
Use SPLIT with a semicolon delimiter: =SPLIT(A2, ";").