TRIM

TRIM statement allows characters to be removed from a string in a number of ways.

COMMAND SYNTAX

    TRIM(expression1 {, expression2{, expression3}})

SYNTAX ELEMENTS

expression1 specifies the string from which to trim characters.

expression2 may optionally specify the character to remove from the string. If not specified then the space character is assumed.

expression3 evaluates to a single character specifies the type of trim to perform.

NOTES

The trim types available for expression3 are:

TypeOperation
Lremoves leading characters only
Tremoves trailing characters only
Bremoves leading and trailing characters
Aremoves all occurrences of the character
Rremoves leading, trailing and redundant characters
Fremoves leading spaces and tabs
Eremoves trailing spaces and tabs
Dremoves leading, trailing and redundant spaces and tabs.

EXAMPLES

       V.STRING = '   A   string  '
    * Get rid of leading spaces
       CRT '"' : TRIM(V.STRING, ' ', 'L') : '"'   ;*    "A   string  "
    * Get rid of trailing spaces
       CRT '"' : TRIM(V.STRING, ' ', 'T') : '"'   ;*    "   A   string"
    * Get rid of leading and trailing spaces
       CRT '"' : TRIM(V.STRING, ' ', 'B') : '"'   ;*    "A   string"
    * Get rid of leading, trailing and redundant spaces
       CRT '"' : TRIM(V.STRING, ' ', 'R') : '"'   ;*    "A string"
    * Get rid of leading zeroes
       CRT '"' : TRIM('000033', '0', 'L') : '"'   ;*    "33"
Last update: Sat, 16 Jul 2022 15:34