Substring.TrimLeft Method

Overload List

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

Overload 1: function TrimLeft: Substring; overload;

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

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

Examples

Leading spaces removed.

uses Substr;

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

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

Moves the window's start CharCount characters on, copying nothing.

#NameTypeDescription
1CharCountInteger

Result: stored in self (calling object)

Remarks:

CharCount must lie in 0 .. Length, else ESubstringRangeError is raised. The underlying text stays, so Index can move the window back.

Examples

Dropping a prefix.

uses Substr;

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

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

The text without the characters of TrimChars at its start.

#NameTypeDescription
1TrimCharsarray of Char

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

Examples

A leading run removed.

uses Substr;

procedure Example;
begin
    Assert(Substring('xxab').TrimLeft(['x']) = 'ab');
end;