System.SysUtils.TStringHelper.IndexOf

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function IndexOf(value: Char): Integer; overload; inline;
function IndexOf(const Value: string): Integer; overload; inline;
function IndexOf(Value: Char; StartIndex: Integer): Integer; overload;
function IndexOf(const Value: string; StartIndex: Integer): Integer; overload;
function IndexOf(Value: Char; StartIndex: Integer; Count: Integer): Integer; overload;
function IndexOf(const Value: string; StartIndex: Integer; Count: Integer): Integer; overload;

Properties

Type Visibility Source Unit Parent
function public System.SysUtils.pas System.SysUtils TStringHelper

Description

Returns an integer that specifies the position of the first occurrence of a character or a substring within this 0-based string, starting the search at StartIndex. This method returns -1 if the value is not found or StartIndex specifies an invalid value.

This method uses the following parameters:

  • StartIndex specifies the initial offset in this 0-based string where the search starts.
  • Count specifies the length of the substring to search for.

Example

var
  MyString: String;

begin
  MyString := 'This is a string.';

  Writeln(MyString.IndexOf('s', 8, 4));
  Writeln(MyString.IndexOf('is', 0));
end.

Output:

10
2

See Also