首先匹配' MX '找到类型MX的位置,然后得出其后最后一个不是空格的字符位置i,再得出其后第二个不是空格的字符位置j,i和j之间的内容就是域名了请高手门详细阅读,根据这段话给我写个例子谢谢!!

解决方案 »

  1.   


    function GetYM(str: string): string;
    var
      i,j:integer;
      temp:string;
    begin
      i:= LastDelimiter(' ',str);
      temp := Copy(str,1,i-1);
      j:= LastDelimiter(' ',temp);
      temp := Copy(str,j,i-j);
      Result := temp;
    end;
      

  2.   

    难道是我调用函数出错?
    能不能把调用涵数和定义MX在
    memo1里显示出来
    谢谢
      

  3.   

    function tform1.GetYM(str: string): string;
    var
      i,j:integer;
      temp:string;
    begin
      i:= LastDelimiter(' ',str);
      temp := Copy(str,1,i-1);
      j:= LastDelimiter(' ',temp);
      temp := Copy(str,j,i-j);
      Result := temp; end;
    procedure TForm1.Button1Click(Sender: TObject);
    var
    fl:TextFile;
    path,str,tmpstr:string;
    TargetStr : TStringlist;begin    OpenDialog1.Filter:='.TXT';
        if OpenDialog1.Execute  then
        path:=opendialog1.FileName;
        AssignFile(fl,path);
        Reset(fl);
        repeat
        Readln(fl,str);
            GetYM(str);
            tmpstr:=trim(copy((str),pos('MX',(str)),length(str)));
            memo1.Lines.Add(tmpstr);        until
        SeekEof(fl);
      CloseFile(fl);end;
    我修改了下写成这样,结果成了
    MX 10 mx1.dns-diy.com.
    MX 10 mx3.dns-diy.com.
    ; authauthority
    hugstone.com. 83957 NS ns8.san.yahoo.com.
    83957 NS yns1.yahoo.com.
    83957 NS yns2.yahoo.com.
    83957 NS ns9.san.yahoo.com.
    ; glue
    huguanghotel.com. 105709 NS ns3.china-enterprise.com.
    105709 NS ns4.china-enterprise.com.
    ; glue
    huguanghuiguan.com. 133833 NS ns1.dns-diy.com.
    其实我只想要:
    MX        mx1.dns-diy.com.
    MX  mx3.dns-diy.com.   
    只要MX和后面对应的域名,其他都不要 
    谢谢
      

  4.   

                            10984   MX 10 mx1.dns-diy.com.
    10984 MX 10 mx3.dns-diy.com.
    ; authauthority
    hugstone.com. 83957 NS ns8.san.yahoo.com.
    83957 NS yns1.yahoo.com.
    83957 NS yns2.yahoo.com.
    83957 NS ns9.san.yahoo.com.
    ; glue
    huguanghotel.com. 105709 NS ns3.china-enterprise.com.
    105709 NS ns4.china-enterprise.com.
    ; glue
    huguanghuiguan.com. 133833 NS ns1.dns-diy.com.
    133833 NS ns2.dns-diy.com.
    ; authauthority
    hugueletconstruction.com. 23325 NS ns1.igpowerhost.net.
    23325 NS ns2.igpowerhost.net.
    ; glue
    原表
      

  5.   


    function GetYM(str: string): string;
    var
      i:integer;
      temp:string;
    begin
      i := Pos('MX',str);
      Result := Copy(str,i,2);
      i:= LastDelimiter(' ',str);
      temp := Copy(str,i,Length(str)-i+1);
      Result := Result + ' ' + temp;
    end;调用
    ShowMessage(GetYM('10984  MX 10 mx1.dns-diy.com.'));返回 MX mx1.dns-diy.com.
      

  6.   

    赋值的str实际字符串内容是什么
      

  7.   

    ShowMessage(GetYM('10984  MX 10 mx1.dns-diy.com.'));返回 MX mx1.dns-diy.com.
    实际字符串:'10984  MX 10 mx1.dns-diy.com.',如果你是多条,循环调用GetYM
      

  8.   

    function tform1.GetYM(str: string): string;
    var
      i:integer;
      temp:string;
    begin
      i := Pos('MX',str);
      Result := Copy(str,i,2);
      i:= LastDelimiter(' ',str);
      temp := Copy(str,i,Length(str)-i+1);
      Result := Result + ' ' + temp;end;
    procedure TForm1.Button1Click(Sender: TObject);
    var
    fl:TextFile;
    path,str,tmpstr:string;
    TargetStr : TStringlist;begin    OpenDialog1.Filter:='.TXT';
        if OpenDialog1.Execute  then
        path:=opendialog1.FileName;
        AssignFile(fl,path);
        Reset(fl);
        repeat
        Readln(fl,str);
            GetYM(str);        memo1.Lines.Add(str);        until
        SeekEof(fl);
      CloseFile(fl);end;
    哪要改?指点,谢谢
      

  9.   


    var 
    fl:TextFile;
    path,str,tmpstr:string;
    TargetStr : TStringlist;
    begin
        OpenDialog1.Filter:='.TXT';
        if OpenDialog1.Execute  then
        path:=opendialog1.FileName;
        AssignFile(fl,path);
        Reset(fl);
        repeat
          Readln(fl,str);
          memo1.Lines.Add(GetYM(str));
        until
        SeekEof(fl);
        CloseFile(fl);
    end;