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

Tips (1541)

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

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

36 Visitors Online


 
...filter out all Links in Memo?
Autor: Ronald Rethfeldt
Homepage: http://www.rogasoft.de
[ Print tip ]  

Tip Rating (3):  
     


{
  For this tip you need Memo1, ListBox1, Label1, Button1.

  Für diesen Tip braucht man ein Memo1, eine ListBox1,
  ein Label1 und einen Button1.
}

procedure TForm1.Button1Click(Sender: TObject);
var 
  
i, p: Integer;
  s: string;
begin
  
ListBox1.Clear;
  for i := 0 to Memo1.Lines.Count - 1 do
  begin
    if 
Pos('http://', Memo1.Lines.Strings[i]) > 0 then
    begin
      
s := '';
      {If the current line contains a "http://", read on until a space is found

       Die aktuelle Zeile wird nach der Zeichenfolge "http://" durchsucht
       und bei Erfolg ab der gefundenen Position ausgelesen, bis ein
       Leerzeichen auftritt...}

      
for p := Pos('http://', Memo1.Lines.Strings[i]) to
        
Length(Memo1.Lines.Strings[i]) do
        if 
Memo1.Lines.Strings[i][p] <> ' ' then
          
s := s + Memo1.Lines.Strings[i][p]
      else
        
break;

       {Remove some characters if address doesn't end with a space

       Falls die gefundene Adresse nicht mit einem Leerzeichen abschließt,
       werden hier noch anhängende Textzeichen entfernt...}

      
while Pos(s[Length(s)], '..;!")]}?''>') > 0 do
        
Delete(s, Length(s), 1);
      // Add the Address to the list...
      //Gefundene Adresse in die Liste aufnehmen...
      
ListBox1.Items.Add(s);
    end;
  end;

  // Show the number of Addresses in Label1
  // Die Zahl der gefundenen Adressen in Label1 anzeigen...

  
if ListBox1.Items.Count > 0 then
    
label1.Caption := IntToStr(ListBox1.Items.Count) +
      ' Adresse(n) gefunden.'
  else
    
label1.Caption := 'Keine Adresse gefunden.';
end;


 

Rate this tip:

poor
very good


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