PosR function
String / Filename routines |
![]() ![]() ![]() |
acUtils
|
function PosR(const SubStr, Str: String): Integer;
|
The PosR function searches for a substring in a string, from right side of the string, unlike standard Pos function.
|
|
PosR searches for the LAST occurence of SubStr within Str (beginning from right side of Str), and returns an integer value that is the index of the first character of SubStr within Str. If SubStr is not found, PosR returns zero.
|
function PosR(const SubStr, Str: String): Integer;
|
var
|
I: Integer;
|
begin
|
if (Length(SubStr) <> 0) and (Length(Str) >= Length(SubStr)) then
|
for I := Length(Str) - Length(SubStr) downto 0 do
|
if Copy(Str, I, Length(SubStr)) = SubStr then
|
begin
|
Result := I;
|
Exit;
|
end;
|
Result := 0;
|
end;
|
LeftPart, RightPart, LeftPartR, RightPartR and SplitStr routines.
|