Unit 'System' Package
[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] [#rtl]

Pos

Search for substring in a string.

Declaration

Source position: systemh.inc line 1293

function Pos(

  const substr: shortstring;

  const s: shortstring;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  C: AnsiChar;

  const s: shortstring;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  const Substr: ShortString;

  const Source: RawByteString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  const substr: shortstring;

  c: AnsiChar;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  const Substr: RawByteString;

  const Source: RawByteString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  c: AnsiChar;

  const s: RawByteString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  const Substr: UnicodeString;

  const Source: UnicodeString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  c: AnsiChar;

  const s: UnicodeString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  c: UnicodeChar;

  const s: UnicodeString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  const c: RawByteString;

  const s: UnicodeString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  const c: UnicodeString;

  const s: RawByteString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  const c: ShortString;

  const s: UnicodeString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  const Substr: WideString;

  const Source: WideString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  c: AnsiChar;

  const s: WideString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  c: WideChar;

  const s: WideString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  c: WideChar;

  const s: RawByteString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  const c: RawByteString;

  const s: WideString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  const c: WideString;

  const s: RawByteString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  const c: ShortString;

  const s: WideString;

  Offset: SizeInt = 1

):SizeInt;

function Pos(

  c: AnsiChar;

  const v: Variant

):SizeInt;

function Pos(

  s: ShortString;

  const v: Variant

):SizeInt;

function Pos(

  const a: AnsiString;

  const v: Variant

):SizeInt;

function Pos(

  const w: WideString;

  const v: Variant

):SizeInt;

function Pos(

  const w: UnicodeString;

  const v: Variant

):SizeInt;

function Pos(

  const v: Variant;

  const c: AnsiChar

):SizeInt;

function Pos(

  const v: Variant;

  const s: ShortString

):SizeInt;

function Pos(

  const v: Variant;

  const a: AnsiString

):SizeInt;

function Pos(

  const v: Variant;

  const w: WideString

):SizeInt;

function Pos(

  const v: Variant;

  const w: UnicodeString

):SizeInt;

function Pos(

  const v1: Variant;

  const v2: Variant

):SizeInt;

Description

Pos returns the index of Substr (or character c)in S, if S contains Substr. In case Substr isn't found, 0 is returned. The search is case-sensitive. The character version uses an optimized version of the search algorithm.

In case Offset is specified, the search starts at position Offset (1-based) in the string; The position Offset is also checked in the search.

Errors

None

See also

Length

  

Returns length of a string or array.

Copy

  

Copy part of a string or dynamic array.

Delete

  

Delete elements (characters) from a string or dynamic array.

Insert

  

Insert one string or dynamic array in another.

posEx

  

Search for the occurrence of a character in a string, starting at a certain position.

Example

Program Example48;

{ Program to demonstrate the Pos function. }

Var
  S : String;

begin
  S:='The first space in this sentence is at position : ';
  Writeln (S,pos(' ',S));
  S:='The last letter of the alphabet doesn''t appear in this sentence ';
  If (Pos ('Z',S)=0) and (Pos('z',S)=0) then
    Writeln (S);
end.

Documentation generated on: Oct 27 2024