[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'sysutils' (#rtl)

# TrimRight

Trim whitespace from the end of a string.

## Declaration

Source position: line 0

`function TrimRight(`
`const S: String`
`):String; function TrimRight(`
`const S: widestring`
`):widestring;`

## Description

Trim strips blank characters (spaces) at the end of S and returns the resulting string. Only #32 characters are stripped. If the string contains only spaces, an empty string is returned.

## Errors

None.

## See also

Trim |  | Trim whitespace from the ends of a string.
TrimLeft |  | Trim whitespace from the beginning of a string.

## Example

    Program Example86;

    { This program demonstrates the TrimRight function }

    Uses sysutils;
    {$H+}

    Procedure Testit (S : String);

    begin
      Writeln ('"',TrimRight(S),'"');
    end;

    Begin
      Testit ('  ha ha what gets lost ? ');
      Testit (#10#13'haha ');
      Testit ('              ');
    End.

The latest version of this document can be found at lazarus-ccr.sourceforge.net.