Skip to content

Text Functions ​

SheetX text functions help you extract, manipulate, and retrieve specific information from text strings in Google Sheets.

Function overview ​

FunctionDescription
SX_TEXT_AFTERExtracts text that appears after a specified delimiter or search string.
SX_TEXT_BEFOREExtracts text that appears before a specified delimiter or search string.
SX_EXTRACT_EMAILExtracts email addresses from a text string.

SX_TEXT_AFTER ​

Extracts the text that appears after a specified delimiter or search string.

Syntax ​

text
=SX_TEXT_AFTER(text_or_range, [delimiter], [instance_num], [match_mode], [match_end], [if_not_found])

Arguments ​

ArgumentDescription
text_or_rangeThe 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

  1. When text_or_range is not specified.
  2. When specified text_or_range is not a string or a range of string.;
  3. When instance_num is zero.
  4. When delimeter is not found in the search text.
  5. When instance_num is greater than the occurence of the delimeter.

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 ​

text
=SX_TEXT_BEFORE(text, [delimiter], [instance_num], [match_mode], [match_end], [if_not_found])

Arguments ​

ArgumentDescription
text_or_rangeThe 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

  1. When text_or_range is not specified.
  2. When specified text_or_range is not a string or a range of string.;
  3. When instance_num is zero.
  4. When delimeter is not found in the search text.
  5. When instance_num is greater than the occurence of the delimeter.

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 ​

text
=SX_EXTRACT_EMAIL(text, [type], [max_occurrences])

Arguments ​

ArgumentDescription
textThe 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 ​
text
  =SX_EXTRACT_EMAIL(text, ':gmail@outlook.com:hotmail')
PrefixDescriptionExample
:Matches a common email provider or domain type.:gmail, :yahoo, ...
@Matches an exact email domain.@company.com.uk, @example.org, ...
Supported Common Domains ​
TypeCommon email domains
:gmailgmail.com
:yahooyahoo.com, yahoo.co.uk, yahoo.co.jp
:outlookoutlook.com
:hotmailhotmail.com, hotmail.co.uk
:livelive.com, live.co.uk
:yandexyandex.com, yandex.ru
:zohozoho.com
:protonproton.me
:protonmailprotonmail.com
:msnmsn.com
:gmxgmx.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.

SheetX text functions can also be combined with native Google Sheets functions to create more advanced text-processing workflows.

FunctionDescription
SPLITDivides text into separate values using a delimiter.
REGEXEXTRACTExtracts matching text using a regular expression.
REGEXREPLACEReplaces matching text using a regular expression.
SUBSTITUTEReplaces occurrences of text with another value.
TRIMRemoves leading, trailing, and repeated spaces.
TEXTJOINCombines text from multiple values using a delimiter.
FILTERFilters 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.