System.SysUtils.TStringHelper.IndexOf

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function IndexOf(Value: Char): Integer; overload;
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 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: Integer that specifies the initial offset in this string where the search starts (0-based).
  • Count: Integer that 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