Overload List
| # | Signature | Description |
|---|---|---|
| 1 | function IndexOf(const C: Char; const StartIndex: Integer = 0): Integer; overload; | |
| 2 | function IndexOf(const C: Char; const StartIndex, Count: Integer): Integer; overload; | |
| 3 | function IndexOf(const S: Substring; const StartIndex: Integer = 0): Integer; overload; | The 0-based index of the first occurrence of S at or after StartIndex. |
| 4 | function IndexOf(const S: string; const StartIndex: Integer = 0): Integer; overload; | |
| 5 | function IndexOf(const S: string; const StartIndex, Count: Integer): Integer; overload; | The first occurrence of S lying wholly inside the Count characters from StartIndex. |
Overload 1: function IndexOf(const C: Char; const StartIndex: Integer = 0): Integer; overload;
| # | Name | Type | Description |
|---|---|---|---|
| 1 | C | Char | |
| 2 | StartIndex | Integer |
Returns: Integer
Overload 2: function IndexOf(const C: Char; const StartIndex, Count: Integer): Integer; overload;
| # | Name | Type | Description |
|---|---|---|---|
| 1 | C | Char | |
| 2 | StartIndex | Integer | |
| 3 | Count | Integer |
Returns: Integer
Overload 3: function IndexOf(const S: Substring; const StartIndex: Integer = 0): Integer; overload;
The 0-based index of the first occurrence of S at or after StartIndex.
| # | Name | Description |
|---|---|---|
| 1 | S | A text of every kind, or a Char. |
| 2 | StartIndex | 0-based, from 0 to Length; outside it ESubstringRangeError is raised. |
Returns: Integer - The index, or -1 when there is none; an empty S is never found.
Examples
Searching a text and a character.
uses Substr;
procedure Example;
var s: Substring;
begin
s := Substring('banana');
Assert(s.IndexOf('an') = 1);
Assert(s.IndexOf('an', 2) = 3);
Assert(s.IndexOf(Char('n')) = 2);
Assert(s.IndexOf('x') = -1);
end;
See Also: Substring.Pos, Substring.Pos
Overload 4: function IndexOf(const S: string; const StartIndex: Integer = 0): Integer; overload;
| # | Name | Type | Description |
|---|---|---|---|
| 1 | S | string | |
| 2 | StartIndex | Integer |
Returns: Integer
Overload 5: function IndexOf(const S: string; const StartIndex, Count: Integer): Integer; overload;
The first occurrence of S lying wholly inside the Count characters from StartIndex.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | S | string | |
| 2 | StartIndex | Integer | |
| 3 | Count | Integer |
Returns: Integer - The 0-based index, or -1.
Remarks:
Only that range is searched; a range outside the text raises ESubstringRangeError.
Examples
A match must lie inside the range.
uses Substr;
procedure Example;
var s: Substring;
begin
s := Substring('banana');
Assert(s.IndexOf('an', 2, 3) = 3);
Assert(s.IndexOf('an', 2, 2) = -1);
end;