Product Site

7.4.63. SUBSTR (Substring)

Returns the substring of string that begins at the nth character and is of length length, padded with pad if necessary. n must be a positive whole number. If n is greater than LENGTH(string), only pad characters are returned.

See also LEFT and RIGHT builtin-functions.

If you omit length, the rest of the string is returned. The default pad character is a blank.

Here are some examples:
Example 7.84. Builtin function SUBSTR
SUBSTR("abc",2)          -->    "bc"
SUBSTR("abc",2,4)        -->    "bc  "
SUBSTR("abc",2,6,".")    -->    "bc...."

Note

In some situations the positional (numeric) patterns of parsing templates are more convenient for selecting substrings, especially if more than one substring is to be extracted from a string.