System.SysUtils.TStringHelper.IndexOf

提供: RAD Studio API Documentation
移動先: 案内検索

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;

プロパティ

種類 可視性 ソース ユニット
function public System.SysUtils.pas System.SysUtils TStringHelper


説明

この文字列の中で、文字またはサブ文字列が現れる位置を示す整数を返します。検索は、StartIndex より開始します。

このメソッドは、値が見つからない、または、StartIndex が不正な値を指定している場合に、-1 を返します。

このメソッドは、次のパラメータを使用します:

  • StartIndex: 検索を開始するこの文字列の初期オフセットを指定する整数(0 始まり)。
  • Count: 検索するサブ文字列の長さを指定する整数。

var
  MyString: String;

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

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

出力は以下のとおりです。

10
2

関連項目