System.SysUtils.TStringHelper.IndexOf
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;
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 paramètre ou d'une sous-chaîne à l'intérieur de cette chaîne, en commençant la recherche au niveau de StartIndex
.
Cette méthode renvoie -1 si la valeur est introuvable ou si StartIndex
spécifie une valeur incorrecte.
Cette méthode utilise les paramètres suivants :
StartIndex
: entier qui spécifie le décalage initial dans cette chaîne lorsque la recherche commence (basée sur 0).Count
: entier qui spécifie la longueur de la sous-chaîne à rechercher.
Exemple
var
MyString: String;
begin
MyString := 'This is a string.';
Writeln(MyString.IndexOf('s', 8, 4));
Writeln(MyString.IndexOf('is', 0));
end.
Sortie :
10 2