z/OS TSO/E REXX Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


SUBSTR (Substring)

z/OS TSO/E REXX Reference
SA32-0972-00

Read syntax diagramSkip visual syntax diagram
>>-SUBSTR(string,n--+-----------------------+--)---------------><
                    '-,-+--------+-+------+-'      
                        '-length-' '-,pad-'        

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

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

Here are some examples:
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. See also the LEFT and RIGHT functions.

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014