Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

TRIM( ) Remove matching characters at the beginning or end of a string

&pagelevel(3)&pagelevel

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' ' / character

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'