Overload List
| # | Signature | Description |
|---|---|---|
| 1 | function LastIndexOf(const C: Char): Integer; overload; | |
| 2 | function LastIndexOf(const C: Char; const StartIndex: Integer): Integer; overload; | |
| 3 | function LastIndexOf(const C: Char; const StartIndex, Count: Integer): Integer; overload; | |
| 4 | function LastIndexOf(const S: Substring): Integer; overload; | The 0-based index of the last occurrence of S. |
| 5 | function LastIndexOf(const S: string): Integer; overload; | |
| 6 | function LastIndexOf(const S: string; const StartIndex: Integer): Integer; overload; | The last occurrence of S lying wholly inside [0, StartIndex], or inside the Count characters that end at StartIndex. |
| 7 | function LastIndexOf(const S: string; const StartIndex, Count: Integer): Integer; overload; |
Overload 1: function LastIndexOf(const C: Char): Integer; overload;
| # | Name | Type | Description |
|---|---|---|---|
| 1 | C | Char |
Returns: Integer
Overload 2: function LastIndexOf(const C: Char; const StartIndex: Integer): Integer; overload;
| # | Name | Type | Description |
|---|---|---|---|
| 1 | C | Char | |
| 2 | StartIndex | Integer |
Returns: Integer
Overload 3: function LastIndexOf(const C: Char; const StartIndex, Count: Integer): Integer; overload;
| # | Name | Type | Description |
|---|---|---|---|
| 1 | C | Char | |
| 2 | StartIndex | Integer | |
| 3 | Count | Integer |
Returns: Integer
Overload 4: function LastIndexOf(const S: Substring): Integer; overload;
The 0-based index of the last occurrence of S.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | S | Substring |
Returns: Integer - The index, or -1 when there is none; an empty S is never found.
Examples
The last occurrence of a text and of a character.
uses Substr;
procedure Example;
var s: Substring;
begin
s := Substring('banana');
Assert(s.LastIndexOf('an') = 3);
Assert(s.LastIndexOf(Char('a')) = 5);
end;
Overload 5: function LastIndexOf(const S: string): Integer; overload;
| # | Name | Type | Description |
|---|---|---|---|
| 1 | S | string |
Returns: Integer
Overload 6: function LastIndexOf(const S: string; const StartIndex: Integer): Integer; overload;
The last occurrence of S lying wholly inside [0, StartIndex], or inside the Count characters that end at StartIndex.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | S | string | |
| 2 | StartIndex | Integer |
Returns: Integer - The 0-based index, or -1.
Remarks:
StartIndex = -1 with Count = 0 is an empty range; a range outside the text raises ESubstringRangeError.
Examples
Searching back from a position.
uses Substr;
procedure Example;
var s: Substring;
begin
s := Substring('banana');
Assert(s.LastIndexOf('an', 2) = 1);
Assert(s.LastIndexOf(Char('a'), 4, 2) = 3);
end;
Overload 7: function LastIndexOf(const S: string; const StartIndex, Count: Integer): Integer; overload;
| # | Name | Type | Description |
|---|---|---|---|
| 1 | S | string | |
| 2 | StartIndex | Integer | |
| 3 | Count | Integer |
Returns: Integer