Skip to main content


TRIM(string_value [ ,flag ] )

string_valueThe string from which to remove spaces.
flagOptional. Specify which spaces to remove. Valid flag values are:

RIGHT (remove trailing spaces--this is the default)

LEFT (remove leading spaces)

LEFT, RIGHT (remove leading and trailing spaces)

ALL (remove all spaces, even those within the string_value)

WHITESPACE removes all white space characters

Return:TRIM returns a single value.

The TRIM function returns the string_value with all trailing and/or leading spaces (0x20) removed.

The WHITESPACE option removes all white space characters. In STRING, this is space (0x20), horizontal tab, vertical tab, line feed, form feed, carriage return (0x09 to 0x0D), and non-breaking space (0xA0). For UNICODE, it removes all characters with the white space property.


  STRING20 SomeStringValue := 'ABC';
  //contains 17 trailing spaces
  VARSTRING MyVal := TRIM(SomeStringValue);
  // MyVal is "ABC" with no trailing spaces
  STRING20 SomeStringValue := ' ABC DEF';
  //contains 2 leading and 11 trailing spaces
  VARSTRING MyVal := TRIM(SomeStringValue,LEFT,RIGHT);
  // MyVal is "ABC DEF" with no trailing spaces