Substring.TrimRight Method

Overload List

#SignatureDescription
1function TrimRight: Substring; overload;The text without the characters <= ' ' at its end.
2procedure TrimRight(const CharCount: Integer); overload;Moves the window's end CharCount characters back, copying nothing.
3function TrimRight(const TrimChars: array of Char): Substr.Substring; overload;The text without the characters of TrimChars at its end.

Overload 1: function TrimRight: Substring; overload;

The text without the characters <= ' ' at its end.

Returns: Substring - The part, as Mid returns it.

Examples

Trailing spaces removed.

uses Substr;

procedure Example;
begin
    Assert(Substring(' ab  ').TrimRight = ' ab');
end;

Overload 2: procedure TrimRight(const CharCount: Integer); overload;

Moves the window's end CharCount characters back, copying nothing.

#NameTypeDescription
1CharCountInteger

Result: stored in self (calling object)

Remarks:

CharCount must lie in 0 .. Length, else ESubstringRangeError is raised.

Examples

Dropping a suffix.

uses Substr;

procedure Example;
var s: Substring;
begin
    s := Substring('abcdef');
    s.TrimRight(2);
    Assert(s = 'abcd');
end;

Overload 3: function TrimRight(const TrimChars: array of Char): Substr.Substring; overload;

The text without the characters of TrimChars at its end.

#NameTypeDescription
1TrimCharsarray of Char

Returns: Substring - The part, as Mid returns it.

Examples

Trailing dots removed.

uses Substr;

procedure Example;
begin
    Assert(Substring('ab..').TrimRight(['.']) = 'ab');
end;