比如有一段文本如下:1 回复:我来留下 
[email protected] 
谢谢 
---------- 
2 回复:我也留下 
[email protected] 
---------- 
3 回复:非常好 
[email protected] 
---------- 现在我只要其中的邮箱部分,其它文字一律删除,最后成这样: [email protected] 
[email protected] 
[email protected] 希望可以给出代码,最好可以给我源码。谢谢。 

解决方案 »

  1.   

    本帖最后由 bdmh 于 2010-09-02 08:34:34 编辑
      

  2.   

    用遍歷的方法,可以把它寫進listbox或memo中然後用while遍歷按"@"分隔再取出地址
      

  3.   

    遍历应该没什么好说的,说下具体每行数据的处理,假如处理结果放在一个Memo里,假如处理的这行数据为'按时打发受到 [email protected] [email protected] '
    如果两邮箱挨着,那就没办法分出来,比如'[email protected][email protected]'Var
      RowStr:String;
    ....  RowStr:='按时打发受到 [email protected] [email protected] ';
      While Pos('@',RowStr)>0 do
        begin
          if Pos(' ',RowStr)>0 then
             begin
               if Pos(' ',RowStr)>Pos('@',RowStr) then
                  Memo1.Lines.Add(Copy(RowStr,1,Pos(' ',RowStr)-1));
               RowStr:=Copy(RowStr,Pos(' ',RowStr)+1,length(RowStr));     
             end
           else
             begin
               Memo1.Lines.Add(RowStr);
               RowStr:='';
             end;
        end;
      

  4.   

    要求不高,就遍历吧,Demo不再重复贴了
      

  5.   

    function GetIt:String;
    var
      i,iPos:integer;f:TextFile;s:String;
    begin
      Result := '';
      AssignFile(f,'c:\a.txt');
      Reset(f);
      while not eof(f) do
      begin
        ReadLn(f,s);
        iPos := Pos('@',s);
        if (iPos > 0) and (PosEx('.',s,iPos+1) > 0) then
        begin
          if Result = '' then
            Result := s
          else
            Result := Result + #13#10 + s;
        end;
      end;
      CloseFile(f);
    end;大致就是这样,或许有几个地方编译不通过,莫怪。手打的。
      

  6.   

    把文本放到一个memo里,遍历每行,如果该行有@那么就把这行取出来放到另一个memo里。最后把另一个memo保存为文本就可以了。
      

  7.   

    对Delphi感兴趣 过来看一下
      

  8.   


    那如果邮箱后面还有数字或者文字呢
    比如:
    "[email protected]  你好啊,怎么办"
    上面这个情况貌似会出现,