SUBSTRING_BETWEEN

Description

Returns the substring found between the first occurrences of the specified open and close substrings within the provided string. If either the open or close substring isn't found, returns an empty string. The search is case-sensitive.

Syntax

SUBSTRING_BETWEEN(string, open, close) -> String

Parameters

ParameterData TypeRequiredDescription
stringStringYesThe original string.
openStringYesThe starting separator.
closeStringYesThe ending separator.

Example

SUBSTRING_BETWEEN("Invoice <INV-2026-009>", "<", ">")
-- Returns "INV-2026-009".

Tips

  • The function returns an empty string if either the open or close delimiter is not found.

  • It locates the first occurrence of the open delimiter and the first occurrence of the close delimiter following it.

  • When the open and close delimiters are identical, the first occurrence is treated as the opening delimiter, and the next occurrence is treated as the closing delimiter. If only one occurrence exists, the function returns an empty string.