Pos function
Search for substring in a string.
Declaration
function Pos(const substr: shortstring; const s: shortstring;
Offset: SizeInt=1): SizeIntDescription
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
Example: ex48
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.An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
