whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1548)

Database (90)
Files (137)
Forms (107)
Graphic (116)
IDE (21)
Indy (5)
Internet / LAN (131)
IntraWeb (0)
Math (76)
Misc (127)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (268)
VCL (243)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

25 Visitors Online


 
...realize a filtered substring search?
Autor: Daniel Elsenhans
[ Print tip ]  

Tip Rating (6):  
     


{+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners