Contact

TEXTBEFORE Function in Apple Numbers: Extract Text Before a Delimiter

Text Intermediate Apple Numbers

Learn how to extract text before a delimiter in Apple Numbers with TEXTBEFORE, choose the first or last match, handle missing matches, and avoid Excel compatibility mistakes.

Verification status: See the evidence and test scope described in this guide. How formula examples are checked

Quick answer: To get everything before a separator in Apple Numbers, enter =TEXTBEFORE(B2,"@"). If B2 contains the text maya@example.ca, the expected result is maya. By default the first match is used, the matching delimiter is excluded, and Apple’s search is not case-sensitive. You can specify a later or last occurrence. Apple’s official TEXTBEFORE documentation establishes these rules.

Verification status: Apple’s Formulas and Functions Help, documentation edition 15.4, was checked on 2026-10-12. The displayed string examples were independently reasoned and checked with a small case-insensitive string-processing script; those are expected outputs, not observations from Numbers. Not executed in Apple Numbers. No genuine Numbers screenshots are included and none have been fabricated.

Availability and version history

  • Introduced: Documented in Apple’s Formulas and Functions Help 15.4; the original introduction release is not established.
  • Availability: Currently documented for Numbers in that help version; it is not a final supported-version endpoint.
  • Scope: Shared iWork function help. Availability in individual clients and older releases is not established by this check.
  • Checked: October 14, 2026, against the official TEXTBEFORE reference. Documentation check; not a new native test.

What TEXTBEFORE does

TEXTBEFORE returns the part of a source value to the left of a matched substring. It is especially useful when product codes, email addresses, export fields, filenames or labels contain predictable separators. Unlike a fixed-width extraction, it adapts when the separator appears at different positions in each row.

An example is an inventory label TOY|CANADA|NEW: matching the first | yields TOY while matching the last | yields TOY|CANADA. The separator is not part of the returned text.

Do not use TEXTBEFORE to extract a fixed number of characters regardless of delimiter location; LEFT is clearer for that job. For the portion after the separator, see Apple’s TEXTAFTER help. For regex-based matching, Apple permits a REGEX expression as the search argument, but regex details require careful testing with the actual pattern.

Exact syntax, arguments, and defaults

=TEXTBEFORE(source-string, search-string, occurrence)

Apple lists the first two arguments as required, and the third argument as optional. Apple TEXTBEFORE — documented syntax.

Argument: source-string

Required
Yes

Type or accepted form
Apple’s documented type: any value

Behaviour
Value to inspect; this guide’s reproducible cases use explicitly stored text.

Argument: search-string

Required
Yes

Type or accepted form
String value, or an Apple-documented REGEX(...) expression

Behaviour
Substring to find. Plain searches are case-insensitive by default.

Argument: occurrence

Required
No

Type or accepted form
Numeric match position: 1, 2, … or -1, -2, …

Behaviour
Default 1. Positive positions count from the beginning; negative positions count from the end.

The function’s result is text to the left of the chosen matching substring. occurrence=1 means the first match; occurrence=-1 means the last. The exact handling of a zero, a noninteger occurrence, and an empty search string is not specified by the consulted Apple TEXTBEFORE page; don’t base a workflow on unverified behaviour for those edge cases.

Formula punctuation and language: In Apple’s English-language formula notation, use a comma between arguments. In regions where the formula decimal separator is a comma, Apple instructs that arguments be separated with semicolons. For example, the English =TEXTBEFORE(B2,"|",-1) becomes =TEXTBEFORE(B2;"|";-1) under those settings. This changes the formula separator—not the literal pipe character inside quotes. See Apple’s function syntax overview. Double quotes around literal strings are required; do not quote a cell reference such as B2.

Platform and version: This is Apple’s current Functions Help edition 15.4, not a claim about which Numbers app release introduced the function. The help supports iWork formulas broadly; the first supporting Numbers version and any Mac/iPad/iPhone/web behavioural differences were not established here. Verify availability in the target app before publishing a version-specific compatibility claim.

Reproducible worksheet: extract parts of imported labels

Create a table named Import Fields with one header row. Set column B to Text before entering the examples, so Numbers does not auto-interpret text. Enter the following B2:B6 values; in C2 enter the shown formula, then use the corresponding formula for each row.

Row: 2

A: Purpose
Email account

B: Source text
maya@example.ca

Formula in column C
=TEXTBEFORE(B2,"@")

Expected text
maya

Row: 3

A: Purpose
First field

B: Source text
TOY|CANADA|NEW

Formula in column C
=TEXTBEFORE(B3,"|")

Expected text
TOY

Row: 4

A: Purpose
Last field split

B: Source text
TOY|CANADA|NEW

Formula in column C
=TEXTBEFORE(B4,"|",-1)

Expected text
TOY|CANADA

Row: 5

A: Purpose
Second pipe

B: Source text
A|B|C|D

Formula in column C
=TEXTBEFORE(B5,"|",2)

Expected text
A|B

Row: 6

A: Purpose
Case-insensitive match

B: Source text
North|SOUTH|East

Formula in column C
=TEXTBEFORE(B6,"|south")

Expected text
North

The outputs can be verified without opening Numbers by scanning the source string from left to right, selecting the requested occurrence, and retaining the characters before it. Apple’s own help independently demonstrates that searches ignore case unless a REGEX expression is used. For more information on referencing cells in other tables, consult Apple’s table-reference guide; this example intentionally uses same-table references so B2 needs no table prefix.

Why positive and negative positions differ

In the source A|B|C|D, the first | follows A, the second follows B, and the last follows C. Therefore:

=TEXTBEFORE("A|B|C|D","|",1)    → "A"       [expected]
=TEXTBEFORE("A|B|C|D","|",2)    → "A|B"     [expected]
=TEXTBEFORE("A|B|C|D","|",-1)   → "A|B|C"   [expected]
=TEXTBEFORE("A|B|C|D","|",-2)   → "A|B"     [expected]

Negative positions select matches from the right, not characters from the right. The result is still the entire prefix before that match.

Case handling and regular expressions

Apple documents case-insensitive plain matching. Thus =TEXTBEFORE("North|SOUTH|East","|south") is expected to return North. This can surprise people coming from Excel, where TEXTBEFORE is normally case-sensitive by default. Apple says that a REGEX(...) expression may be supplied for more complex searches and to make case matter. See the official TEXTBEFORE notes. This is not the same as Excel’s separate match_mode argument.

A regex might need escaping for literal punctuation. Check the pattern in Numbers before relying on it for sensitive identifiers or mixed Unicode text. This guide does not assign observed results to regex examples that weren’t tested natively.

Practical formulas beyond a simple prefix

Remove a suffix after the last delimiter: =TEXTBEFORE(B2,"|",-1) can preserve a multi-part inventory code’s earlier segments. If B2 is SKU|BATCH|2026, the expected result is SKU|BATCH.

Split an email into two fields: With B2 as maya@example.ca, use =TEXTBEFORE(B2,"@") for the local part. Use =TEXTAFTER(B2,"@") for the domain in a separate result cell; the latter’s syntax is checked in Apple TEXTAFTER. Neither function validates that the original is a standards-compliant email address.

Return a helpful label when a delimiter is missing:

=IFERROR(TEXTBEFORE(B2,"@"),"Check input")

When B2 lacks @, Apple documents that TEXTBEFORE returns an error, and IFERROR can supply the fallback message. This catches errors beyond missing separators too, so it is not a complete validation routine.

Work across tables: If B2 in a different table named Import Fields holds the source, the Apple reference syntax permits references such as Import Fields::B2 when table qualification is required. Prefer selecting the cell using Numbers’ formula editor if a table name contains spaces or references are ambiguous.

Error behaviour, constraints, and troubleshooting

Symptom Likely explanation What to check
Error when delimiter is absent Apple explicitly returns an error when the search string is not found. Confirm capitalization isn’t the issue (ordinary searches already ignore case); check spaces and punctuation.
Error when an occurrence cannot be found Requested occurrence is outside the available matches. Count delimiters and reduce the requested index; use -1 for the last available match.
Returned prefix is shorter than expected A substring matched an earlier occurrence than intended. Supply 2, 3, or -1, and inspect repeated delimiters.
Output seems wrong for regional formulas Argument separators differ with regional decimal settings. Replace argument commas with semicolons where required, without editing text inside quotes.
Unexpected case-insensitive match Plain search-string matching ignores case by default. If case must matter, review Apple’s REGEX alternative, then test the pattern in Numbers.
A copied formula references the wrong row Cell references moved relatively. Inspect referenced cells and use explicit cross-table references where appropriate.

Apple’s help does not identify an exact error token for every invalid input in the conditions above. Unlike Excel’s published #N/A or #VALUE! handling, this guide intentionally avoids assigning those codes to Apple Numbers without native testing. It also does not assert undocumented behaviour for blank delimiters, regex failures, or fraction-valued match positions.

Apple Numbers versus Microsoft Excel

Apple’s documented signature is three positions: TEXTBEFORE(source-string, search-string, occurrence). Microsoft’s Excel TEXTBEFORE reference documents six positions, adding match_mode, match_end and if_not_found. Excel’s default matching is case-sensitive, while Apple’s regular substring search is case-insensitive. Both document negative occurrence indices, but that does not establish identical edge-case error handling or zero/blank delimiter behaviour.

Do not copy a six-argument Excel formula into Numbers or assume Excel’s error codes and match_mode=1 carry over. Google Sheets alternatives can use LEFT combined with SEARCH or other text tools, but this guide does not assert direct formula compatibility or equal error handling across Google Sheets versions.

  • CHAR — continue with a related Apple Numbers calculation.
  • CODE — continue with a related Apple Numbers calculation.
  • CLEAN — continue with a related Apple Numbers calculation.
  • T — continue with a related Apple Numbers calculation.
  • REPT — continue with a related Apple Numbers calculation.

For a software-specific comparison: Microsoft Excel TEXTBEFORE, LibreOffice Calc TEXTBEFORE, Gnumeric TEXTBEFORE. A shared name does not establish identical argument, error or version behaviour.

How this guide was checked

The linked official function documentation was reviewed on October 12, 2026. Apple’s Formulas and Functions Help 15.4 identifies the documentation edition, not a minimum Numbers release or a guarantee of historical platform parity. Selected worked examples were checked using independent mathematical or text-processing models; results are expected values, not observations from the spreadsheet application. Native Apple Numbers execution was not performed. Undocumented coercion, exact error messages and platform-specific behaviour remain unverified.

View reproducible example inputs and independent check results. This record is not a native spreadsheet test log.