SUBSTR()
function extracts a specific number of characters from a string.
string
.start_position
is used as the starting position, specifying the part from where the substring is to be returned. It is written as an integer value.
Input | Return |
---|---|
start_position < 0 ``start_position < string | The start_position is a given character in the string. The count starts from the first character. |
start_position > string | Returns an empty substring. |
start_position = negative value | The count starts from the provided negative value, with subsequent characters yielded as it approaches 0. If the index is less than or equal to 0, no characters are returned. Once it exceeds 0, characters from the string are yielded, starting from the first one. |
length
is used to determine the number of characters to be extracted*. *It can be one or more characters.
Input | Return |
---|---|
length = 0 | Returns an empty substring. |
length is not set | The function will start from the specified start_position and end at the last character of the string . |
length = negative value | Returns an error. |
SUBSTR()
function with specified start_position
& length
start_position
with the first six characters and have five characters extracted:
SUBSTR()
function with length
= 0length
= 0:
length
specified:
SUBSTR()
function with length
= negative valuelength
is specified with a negative value:
SUBSTR()
function with start_position
> string
start_position
is larger than the string’s characters:
SUBSTR()
Function with 2 Argumentsstart_position
with the first six characters and have five characters extracted.