Domain: string functions
The TRIM( ) function removes matching characters at the beginning, end or both ends of a string.
Format
TRIM( ) |
STRING = string_expression ,SIDE = *BOTH / *LEFT / *RIGHT ,TRIM-BYTE = C' |
Result type
STRING
Input parameters
STRING = string_expression
Designates an expression of type STRING is to be processed.
SIDE = *BOTH / *LEFT / *RIGHT
The character specified in the TRIM-BYTE parameter is removed from the beginning of the string (*LEFT), from its end (*RIGHT) or from both ends (*BOTH) over and over until a different character appears. If the string does not contain any different character, the function returns a null string.
TRIM-BYTE = C'
' / character
Designates the character (as a C literal) to be removed. Default value: blank (space character). Blank is assumed when a null string (C''
) is entered.
Result
String shortened form
Error messages
No error messages
Example
/A = ' ABC ' /B = ' ABC000' /A = TRIM(STRING=A) /B = TRIM(STRING=B,SIDE=*LEFT,TRIM-BYTE=' ') /B = TRIM(STRING=B,SIDE=*RIGHT,TRIM-BYTE='0') /SHOW-VARIABLE VALUE = *C-LITERAL A = 'ABC' B = 'ABC'