SUBSTRING_BEFORE
Description
Returns the substring that occurs before the first 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_BEFORE(string, separator) -> String
Parameters
| Parameter | Data Type | Required | Description |
|---|---|---|---|
| string | String | Yes | The original string. |
| separator | String | Yes | The separator to search for within the string. |
Example
SUBSTRING_BEFORE("REF-2025-1234", "-")
-- Returns "REF".
-- Extracts the substring before the first occurrence of "-".Tips
The function returns an empty string if any of these occur:
the separator appears at the beginning of the string,
the separator is an empty string.
If the separator is not found in the string, the function returns the entire string.