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 NULL. The search is case-sensitive.

Syntax

SUBSTRING_BETWEEN(string, open, close) -> String

Parameters

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

Example

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

Tips

  • 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 NULL.