SUBSTRING_AFTER_LAST

Description

Returns the substring that occurs after the last occurrence of the specified separator within the provided string. If the separator is not found, returns an empty string. The search is case-sensitive.

Syntax

SUBSTRING_AFTER_LAST(string, separator) -> String

Parameters

ParameterData TypeRequiredDescription
stringStringYesThe original string.
separatorStringYesThe separator to search for within the string.

Example

SUBSTRING_AFTER_LAST("REF-2025-1234", "-")
-- Returns "1234".
-- Extracts the substring after the last occurrence of "-".

Tips

  • The function returns an empty string if any of these occur:

    • the separator is not found in string,

    • the separator appears at the end of string,

    • the separator is an empty string.