...realize a filtered substring search?
Author: Daniel Elsenhans
{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Funktion zum Filtern mehrerer Substrings innerhalb eines Strings
bezüglich zweier Trennzeichen.
Aufruf:
filterSubStr([String der durchsucht werden soll],[suchen von],[suchen bis],[wie oft durchsucht werden soll])
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Search for a substring positioned between 2 markers.
Call:
filterSubStr([Fullstring],[first mark],[second mark],[repeated searching])
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++}
function filterSubStr(tmp, von, bis: string; a: Integer): string;
var
SubStr, bck: string;
Pos1, Pos2, i: Integer;
begin
i := 0;
while i < a do
begin
Pos1 := Pos(von, tmp);
Pos2 := Pos(bis, tmp);
SubStr := Copy(tmp, Pos1 + Length(von), Pos2 - Pos1 - Length(von));
Delete(tmp, Pos1, Pos2 - Pos1 + Length(bis));
if SubStr = '' then {nothing}
else if bck = '' then
bck := SubStr
else
bck := bck + #13#10 + SubStr;
i := i + 1;
end;
Result := bck;
end;
printed from
www.swissdelphicenter.ch
developers knowledge base