TRIM (Text) TRIM (Text)

Text

Text Text

The text string to trim.

Returns

Text Text

The resulting text string.

Removes any excess whitespace characters (such as space characters) from a text string and returns the modified text string. TRIM ("  abc   def  ") TRIM ("  abc   def  ") returns "abc def".

All leading and trailing whitespace characters are removed, and all occurrences of multiple whitespace characters joined together are replaced with single space characters.

The spreadsheet versions of TRIM typically only remove space characters, not all whitespace characters. An example of a whitespace character which is not a space character is the non-breaking space character, which prevents line breaking from taking place, and is often found in HTML documents.

Examples

TRIM ("  abc   def  ")
TRIM ("  abc   def  ")

Returns "abc def".

TRIM ("  abc " & REPT ( CHAR (160), 10) & "  def  ")
TRIM ("  abc " & REPT ( CHAR (160); 10) & "  def  ")

Returns "abc def". REPT ( CHAR (160), 10) REPT ( CHAR (160); 10) returns ten non-breaking space characters, which TRIM also removes.

TRIM ({ "  abc   def  ", " 1 2  3 " })
TRIM ({ "  abc   def  "; " 1 2  3 " })

Returns the array { "abc def", "1 2 3" }{ "abc def"; "1 2 3" }.

fxEngine Shell Want this in your own terminal? A standalone version is coming. Get notified.
Loading fxEngine Shell