Text Functions
SheetX text functions help you extract, manipulate, and retrieve specific information from text strings in Google Sheets.
Function overview
| Function | Description |
|---|---|
SX_TEXT_AFTER | Extracts text that appears after a specified delimiter or search string. |
SX_TEXT_BEFORE | Extracts text that appears before a specified delimiter or search string. |
SX_EXTRACT_EMAIL | Extracts email addresses from a text string. |
SX_TEXT_AFTER
Extracts the text that appears after a specified delimiter or search string.
Syntax
=SX_TEXT_AFTER(text_or_range, [delimiter], [instance_num], [match_mode], [match_end], [if_not_found])Arguments
| Argument | Description |
|---|---|
text_or_range | The text or range of text from which to extract a portion. |
[delimiter] | The text that marks the boundary after which extraction begins. Default: "" |
[instance_num] | The occurrence of the delimiter to use. Default: 1 |
[match_mode] | Specifies whether the delimiter comparison is case-sensitive.0 - Case sensitive;1 - Case insensitive;Default: 0 |
[match_end] | Determines whether the end of the text is treated as a delimiter when a match is not found at the end.0 - Don't match the delimeter against the end of the text;1 - Match the delimeter against the end of the text.Default: 0 |
[if_not_found] | Value to show when no match is found. |
Throws
- When
text_or_rangeis not specified. - When specified
text_or_rangeis not a string or a range of string.; - When
instance_numis zero. - When
delimeteris not found in the search text. - When
instance_numis greater than the occurence of thedelimeter.
Use cases
- Extract product identifiers from structured product codes.
- Retrieve email addresses or other values following labels.
- Separate filenames from directory paths.
- Extract specific sections from formatted text.
- Process imported data containing consistent delimiters.
SX_TEXT_BEFORE
Extracts the text that appears before a specified delimiter or search string.
Syntax
=SX_TEXT_BEFORE(text, [delimiter], [instance_num], [match_mode], [match_end], [if_not_found])Arguments
| Argument | Description |
|---|---|
text_or_range | The text or range of text from which to extract a portion. |
[delimiter] | The text that marks the boundary after which extraction ends. Default: "" |
[instance_num] | The occurrence of the delimiter to use. Default: 1 |
[match_mode] | Specifies whether the delimiter comparison is case-sensitive.0 - Case sensitive;1 - Case insensitive;Default: 0 |
[match_end] | Determines whether the end of the text is treated as a delimiter when a match is not found at the end.0 - Don't match the delimeter against the end of the text;1 - Match the delimeter against the end of the text.Default: 0 |
[if_not_found] | Value to show when no match is found. |
Throws
- When
text_or_rangeis not specified. - When specified
text_or_rangeis not a string or a range of string.; - When
instance_numis zero. - When
delimeteris not found in the search text. - When
instance_numis greater than the occurence of thedelimeter.
Use cases
- Extract prefixes from product codes or identifiers.
- Separate usernames from domain names.
- Retrieve names or labels from structured text.
- Extract directory names from file paths.
- Split text fields using known delimiters.
SX_EXTRACT_EMAIL
Extracts email addresses from a text string and returns them as an array. It can identify email addresses embedded in sentences, messages, and other unstructured text, making it useful for collecting contact information from larger datasets.
NOTE
The function supports only unquoted local parts, as well as email aliases containing a plus sign.
Syntax
=SX_EXTRACT_EMAIL(text, [type], [max_occurrences])Arguments
| Argument | Description |
|---|---|
text | The text string from which to extract email addresses. |
[type] | The type(s) of email addresses to extract. Each type argument must begin with either @ or :. Read more on type.Defualt: :email for generic email. |
[max_occurrences] | The maximum number of found email instances in the search text. NOTE: You must ensure you have enough columns to accommodate your specified max_occurrences. |
type Argument
You can provide multiple type arguments to match different email providers or specific email domains.
Each type argument must begin with either : or @, depending on how you want the email domain to be matched.
Syntax for multiple types
=SX_EXTRACT_EMAIL(text, ':gmail@outlook.com:hotmail')| Prefix | Description | Example |
|---|---|---|
: | Matches a common email provider or domain type. | :gmail, :yahoo, ... |
@ | Matches an exact email domain. | @company.com.uk, @example.org, ... |
Supported Common Domains
| Type | Common email domains |
|---|---|
:gmail | gmail.com |
:yahoo | yahoo.com, yahoo.co.uk, yahoo.co.jp |
:outlook | outlook.com |
:hotmail | hotmail.com, hotmail.co.uk |
:live | live.com, live.co.uk |
:yandex | yandex.com, yandex.ru |
:zoho | zoho.com |
:proton | proton.me |
:protonmail | protonmail.com |
:msn | msn.com |
:gmx | gmx.com, gmx.net, gmx.de |
Use cases
- Extract email addresses from customer support messages.
- Collect contact information from unstructured text.
- Identify email addresses in survey responses.
- Extract multiple addresses from a single cell.
- Prepare email lists from imported or copied text.
- Find contact addresses in notes, descriptions, or communication logs.
Related Google Sheets functions
SheetX text functions can also be combined with native Google Sheets functions to create more advanced text-processing workflows.
| Function | Description |
|---|---|
SPLIT | Divides text into separate values using a delimiter. |
REGEXEXTRACT | Extracts matching text using a regular expression. |
REGEXREPLACE | Replaces matching text using a regular expression. |
SUBSTITUTE | Replaces occurrences of text with another value. |
TRIM | Removes leading, trailing, and repeated spaces. |
TEXTJOIN | Combines text from multiple values using a delimiter. |
FILTER | Filters a range or array based on specified conditions. |
Use SheetX text functions alongside these tools to automate text extraction, data cleaning, and information processing directly in Google Sheets.
