PosI function
A case-insensitive optimized version of the Pos routine.
Declaration
function PosI(const SubStr: string; const S: string): IntegerArguments
SubStr | Value to locate in the searched value. |
S | Value searched for the specified sub-string. |
Function result
Position of the sub-string within the searched value, or 0 when not found.
Description
PosI implements a case-insensitive optimized version of the
Pos routine found the RTL
system unit. It only
accepts
String values in its parameters, unlike the RTL overloaded
variants which accept combinations of the Char, ShortString, AnsiString,
UnicodeString, WideString, and Variant types.
It is also an alternative to the ContainsText routine in the RTL
StrUtils unit, which has a very slow implementation.
SubStr contains the value to locate in
S.
PosI supports ASCII comparison. It converts the values in SubStr and S to lowercase char by char for fast comparisons. The result is much faster than Pos(Lowercase(SubStr),Lowercase(S)) which is often used.
The return value contains the position in S where SubStr is located, or 0 when SubStr does not occur in S. The position is 1-based just like indexed access to values in the String type.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
