Documentation/Calc Functions/TRIM

    From The Document Foundation Wiki
    Other languages:


    Function name:

    TRIM

    Category:

    Text

    Summary:

    Removes excess spaces from a supplied text string.

    Syntax:

    TRIM(Text)

    Returns:

    Returns a text string that is based on the supplied string, but with leading and trailing spaces removed and sequences of internal spaces replaced with a single space character.

    Arguments:

    Text is a text string (in quotation marks), or a reference to a cell containing a text string, that is the string from which spaces are to be removed.

    Additional details:

    TRIM removes space characters (Unicode U+0020) but does not remove other white-space characters such as horizontal tab (U+0009), line feed (U+000A) or carriage return (U+000D). In this respect the function is not fully compliant with ODF 1.2 but this behaviour is compatible with other major office suites.

    Examples:

    Formula Description Returns
    =TRIM("    Good     morning   ") Here the function removes four leading spaces and three trailing spaces. It also reduces the five spaces between "Good" and "morning" to one. "Good morning"
    =TRIM(D1) where cell D1 contains the string "   Hello   World!   ". Here the function removes three leading spaces and three trailing spaces. It also reduces the three spaces between "Hello" and "World!" to one. "Hello World!"

    Related LibreOffice functions:

    None.

    ODF standard:

    Section 6.20.24, part 2.

    Related (or similar) Excel functions:

    TRIM