System.SysUtils.TStringHelper.IndexOf

De RAD Studio API Documentation
Aller à : navigation, rechercher

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;

Propriétés

Type Visibilité  Source Unité  Parent
function public System.SysUtils.pas System.SysUtils TStringHelper


Description

Renvoie un entier qui spécifie la position de la première occurrence d'un caractère ou d'une sous-chaîne à l'intérieur de cette chaîne de base zéro, en commençant la recherche à StartIndex. Cette méthode renvoie -1 si la valeur est introuvable ou si StartIndex spécifie une valeur non valide.

Cette méthode utilise les paramètres suivants :

  • StartIndex spécifie le décalage initial dans cette chaîne de base zéro où commence la recherche.
  • Count spécifie la longueur de la sous-chaîne à chercher.

Exemple

var
  MyString: String;
begin
  MyString := 'Ceci est une chaîne.';
  Writeln(MyString.IndexOf('s', 8, 4));
  Writeln(MyString.IndexOf('is', 0));
end.

Sortie :

10
2

Voir aussi