Pos

Declaration:
Function Pos (Const Substr : String;Const S : String) : Integer;
Description:
Pos returns the index of Substr in S, if S contains Substr. In case Substr isn’t found, 0 is returned. The search is case-sensitive.
Errors:
None
See also:
Length (527), Copy (477), Delete (481), Insert (521)

Listing: refex/ex48.pp


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.