SUBSTR or SUBSTRING
Syntax
SUBSTR(string_value, start_pos[, nchars]) or SUBSTR(string_value FROM start_pos[ FOR nchars]) SUBSTRING(string_value, start_pos[, nchars]) or SUBSTRING(string_value FROM start_pos[ FOR nchars])
Parameters
string_value
The string from which a substring will be taken.
start_pos
The starting character from each the substring will be extracted.
nchars
The number of characters to be extracted (must be greater than or equal to 0). If this value is not provided, all remaining characters in string_value are extracted.
Description
SUBSTR or SUBSTRING extracts nchars characters from the string, starting at start_pos. If nchars is omitted, SUBSTR and SUBSTRING extracts characters from start_pos through the end of the string. Trailing spaces are automatically truncated.
This macro is available in IBM® Interact.
*
IBM® Interact supports the following formats only: SUBSTR(string_value, start_pos[, nchars]) or SUBSTRING(string_value, start_pos[, nchars])
Examples
SUBSTR SUBSTR Returns
("abcdef" FROM 1 FOR 2) ("abcdef",1,2) 'ab'
SUBSTR SUBSTR Returns
("abcdef" FROM -2 FOR 4) ("abcdef",-2,4) 'a'
SUBSTR SUBSTR Returns
("abcdef" FROM 3) ("abcdef",3) 'cdef'