TEXTAFTER Function (LibreOffice Calc)

Text Intermediate LibreOffice Calc Introduced in LibreOffice 24.2
text extraction delimiter parsing cleaning modern-functions

The TEXTAFTER function in LibreOffice Calc extracts text that appears after a specified delimiter. It supports instance selection, case sensitivity options, and default return values, making it a modern and powerful text-extraction tool.

Compatibility

β–Ύ

What the TEXTAFTER Function Does β–Ύ

  • Extracts text after a delimiter
  • Supports selecting the Nth occurrence
  • Supports case-sensitive or insensitive matching
  • Allows a default value if the delimiter is missing
  • Works with text, numbers (converted to text), and formulas

It is designed to be clean, modern, and extremely flexible.

Syntax β–Ύ

TEXTAFTER(text; delimiter; [instance]; [match_mode]; [match_end]; [if_not_found])

Arguments

  • text:
    The text to extract from.

  • delimiter:
    The text or pattern to search for.

  • instance: (optional)
    Which occurrence to use (default = 1).

    • 1 β†’ first occurrence
    • 2 β†’ second occurrence
    • -1 β†’ last occurrence
    • -2 β†’ second-last occurrence
  • match_mode: (optional)

    • 0 β†’ case-sensitive (default)
    • 1 β†’ case-insensitive
  • match_end: (optional)

    • 0 β†’ delimiter must be fully matched (default)
    • 1 β†’ match delimiter at end of text
  • if_not_found: (optional)
    Value to return if delimiter is missing (default = #N/A).

Basic Examples β–Ύ

Extract text after the first hyphen

=TEXTAFTER("A-B-C"; "-")

Returns "B-C".

Extract text after the second hyphen

=TEXTAFTER("A-B-C"; "-"; 2)

Returns "C".

Extract text after the last hyphen

=TEXTAFTER("A-B-C"; "-"; -1)

Returns "C".

Case-insensitive extraction

=TEXTAFTER("HelloWORLD"; "world"; 1; 1)

Returns "" (empty string after the delimiter).

Provide a default value if delimiter missing

=TEXTAFTER("ABC"; "-"; 1; 0; 0; "Not found")

Returns "Not found".

Advanced Examples β–Ύ

Extract file extension

=TEXTAFTER(A1; "."; -1)

Extract domain from email

=TEXTAFTER(A1; "@")

Extract everything after the first space

=TEXTAFTER(A1; " ")

Extract everything after the second space

=TEXTAFTER(A1; " "; 2)

Extract text after a long delimiter

=TEXTAFTER(A1; " - ")

Extract after a dynamic delimiter

=TEXTAFTER(A1; B1)

Extract after a delimiter only if present

=TEXTAFTER(A1; "-"; 1; 0; 0; A1)

Extract after a delimiter in CSV-like text

=TEXTAFTER(A1; ","; 1)

Extract after the last slash in a file path

=TEXTAFTER(A1; "/"; -1)

Extract after a substring ignoring case

=TEXTAFTER(A1; B1; 1; 1)

Extract after a delimiter that appears many times

=TEXTAFTER(A1; "|"; 5)

Extract after a delimiter at end of string

=TEXTAFTER("ABC-"; "-"; 1; 0; 1)

Returns "".

Edge Cases and Behavior Details β–Ύ

Missing delimiter β†’ #N/A unless if_not_found provided

=TEXTAFTER("ABC"; "-") β†’ #N/A

instance < 0 counts from the end

=TEXTAFTER("A-B-C-D"; "-"; -2) β†’ "C-D"

instance too large β†’ #N/A

=TEXTAFTER("A-B"; "-"; 5) β†’ #N/A

match_mode controls case sensitivity

=TEXTAFTER("ABCdef"; "DEF"; 1; 1) β†’ ""

match_end allows matching delimiter at end

=TEXTAFTER("ABC-"; "-"; 1; 0; 1) β†’ ""

text is a number β†’ converted to text

=TEXTAFTER(2024; "2") β†’ "024"

delimiter is empty β†’ Err:502

text is empty β†’ returns empty string

TEXTAFTER of an error propagates the error

=TEXTAFTER(#N/A; "-") β†’ #N/A

Common Errors and Fixes β–Ύ

#N/A β€” Delimiter not found

Fix:
Provide an if_not_found value.

Err:502 β€” Invalid argument

Occurs when:

  • delimiter is empty
  • instance is non-numeric
  • match_mode invalid

Unexpected extraction

Cause:

  • Case sensitivity mismatch
  • Wrong instance number
  • Hidden characters in delimiter

Fix:
Use CLEAN, TRIM, or SUBSTITUTE.

Best Practices β–Ύ

  • Use TEXTAFTER instead of FIND/SEARCH/MID chains
  • Use negative instance values to extract from the end
  • Use match_mode for case-insensitive extraction
  • Always provide if_not_found for robust formulas
  • Combine with TEXTBEFORE for full delimiter-based parsing
  • Use TRIM and CLEAN before extraction for reliability
TEXTAFTER is your modern extraction engine β€” perfect for clean, readable, and robust delimiter-based parsing without the complexity of legacy formulas.

Related Patterns and Alternatives β–Ύ

  • Use TEXTBEFORE to extract text before a delimiter
  • Use SEARCH or FIND for positional extraction
  • Use MID, LEFT, RIGHT for manual parsing
  • Use SPLIT (future Calc versions) for array-based splitting
  • Use SUBSTITUTE for targeted cleanup

By mastering TEXTAFTER and its companion functions, you can build powerful, modern, and highly readable text‑processing workflows in LibreOffice Calc.

Copyright 2026. All rights reserved.