a id="ctl00_CenterRegion_ctl00_ctl00_TextList_ctl04_IconUrl" href="http://www.xxx.xxx/6271009.rar" target="_blank"> 
################################################## 
<a id="ctl00_CenterRegion_ctl00_ctl00_TextList_ctl19_IconUrl" href="http://www.xxx.xxx/6270904.rar" target="_blank"> 
################################################## 
<a id="ctl00_CenterRegion_ctl00_ctl00_TextList_ctl23_IconUrl" href="http://www.xxx.xxx/6271009.rar" target="_blank"> 
################################################## 
<a id="ctl00_CenterRegion_ctl00_ctl00_TextList_ctl71_IconUrl" href="http://www.xxx.xxx/6270912.rar" target="_blank"> 
################################################## 
如何将里面的HTTP://XXXX.RAR 提取到MEMO中? 主要是循环我不会写.... 
function CenterStr(Src:String;Before,After:String):String; 
  var 
    Pos1,Pos2:WORD; 
  begin 
    Pos1:=Pos(Before,Src)+Length(Before); 
    Pos2:=Pos(After,Src); 
    Result:=Copy(Src,Pos1,Pos2-Pos1); 
  end;   Const 
  A ='IconUrl" href="'; 
  B ='" target="_blank">';  memo.Lines.Add(CenterStr(str,A,B)); 这样只能提取出第一个URL来(http://www.xxx.xxx/6271009.rar) 如何写循环啊...头晕啊.... 小弟菜鸟.....希望大虾别笑话我... 

解决方案 »

  1.   

    function TForm1.CenterStr(Src,Before,After:String):String;
    var
      Pos1,Pos2:WORD;
    begin
      Pos1:=Pos(Before,Src)+Length(Before);
      Pos2:=Pos(After,Src);
      Result:=Copy(Src,Pos1,Pos2-Pos1);
    end;procedure TForm1.InsertMemo(Src,Before,After:String);
    var
      Str1:string;
    begin
      Str1 := Src;
      while ((Pos(Before,Str1)+Length(Before)) <> 0) and (Pos(after,Str1) <> 0)do
      begin
        memo1.Lines.Add(CenterStr(Str1,Before,After));
        Str1 := Copy(Str1,Pos(after,Str1)+Length(after),length(Str1)-(Pos(after,Str1)+Length(after))+1)
      end;
    end;procedure TForm1.Button1Click(Sender: TObject);
    begin
      InsertMemo('a123b123123a123123b123123a212342b','a','b');
    end;
      

  2.   

    Const 
      A ='IconUrl" href="'; 
      B ='" target="_blank">';
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      InsertMemo(str,A,B);
    end;