TStringHelper.IndexOf

Find the position (index) of a string or character

Declaration

Source position: syshelph.inc line 111

public 
  function IndexOf(AValue: Char) : SizeInt;  Overload;
  function IndexOf(const AValue: string) : SizeInt;  Overload;
  function IndexOf(AValue: Char; StartIndex: SizeInt) : SizeInt;  Overload;
  function IndexOf(const AValue: string; StartIndex: SizeInt) : SizeInt
                  ;  Overload;
  function IndexOf(AValue: Char; StartIndex: SizeInt; ACount: SizeInt)
                   : SizeInt;  Overload;
  function IndexOf(const AValue: string; StartIndex: SizeInt; 
                  ACount: SizeInt) : SizeInt;  Overload;

Description

IndexOf returns the zero-based index of AValue in the string (Self). The value to search for can be a character or string (AValue).

if no match is found, -1 is returned.

The search can be refined by specifying a (zero based) index StartIndex. When specified, the search will start at the given character. Not specifying this option is equivalent to specifying zero.

If ACount is given, at most ACount characters in the source string will be considered for the search. This count includes the starting character. Not specifying this argument is equivalent to specifying the amount of remaining characters.

See also

Name Description
Pos Search for substring in a string.
TStringHelper.IndexOfAny Find the position (index) of any string or character in a list.
TStringHelper.IndexOfAnyUnquoted Find the position (index) of any string or character in a list.
TStringHelper.IndexOfUnQuoted Index of string, skipping quoted parts.
TStringHelper.LastIndexOf Find the last position (index) of a string or character
TStringHelper.LastIndexOfAny Find the last position (index) of any string or character in a list.