System.Pos

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function Pos(const SubStr, Str: _ShortStr; Offset: Integer): Integer;
function Pos(const SubStr, Str: UnicodeString; Offset: Integer): Integer; overload;
function Pos(const SubStr, Str: _WideStr; Offset: Integer): Integer; overload;
function Pos(const SubStr, Str: _RawByteStr; Offset: Integer): Integer;

C++

extern DELPHI_PACKAGE int __fastcall Pos(const ShortString &SubStr, const ShortString &Str, int Offset = 0x1)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
System.pas
System.hpp
System System

Description

Locates a substring in a given string.

The Pos method returns the index of the first occurence of Substr in Str, starting the search at Offset.

This method returns zero if Substr is not found or Offset is invalid (for example, if Offset exceeds the String length or is less than 1).

The Offset argument is optional. Offset is set to 1 by default, if no value for Offset is specified it takes the default value to start the search from the beginning.

Notes:
  • Pos uses one-based array indexing even in platforms where the strings are zero-based.
  • Pos method is equivalent to System.StrUtils.PosEx.


See Also

Code Examples