LEFT

LEFT returns the leftmost segment of a string, as specified by a segment position argument.

To get characters from the right side of a string, use RIGHT. Unlike RIGHT, the segment position argument for LEFT is counted from left to right, as opposed to right to left.

Syntax

LEFT(arg1, arg2)

Arguments

Description

arg1

String to be segmented.

arg2

Optional. The position at which to segment the strings. Default is 1.

Example

Let's say we're given the following response that includes an id string.

{
"data": {
"ids": {
"id_1": "1anb4amca051"
}
}
}

If we are only interested in the first 5 digits of id_1, use the following function.

# Find 5 digits starting from the left
LEFT(data.ids.id_1, 5)
‚Äč
# Returns 1anb4