如:http://news.xinhuanet.com/tech/2006-07/14/content_4831708.htm
<IMG style="WIDTH: 400px; HEIGHT: 283px" alt="" hspace=0 src="xinsrc_1020703140958859330618.jpg" border=1>实际上我只要得到
xinsrc_1020703140958859330618.jpg 这个值就可以了可用正则表达式,但不会中...

解决方案 »

  1.   

    function TForm1.ExtractPictureName;
    var
      content: String;
      r: TRegExpr;
    const
      pattern = '<IMG style="WIDTH: 400px; HEIGHT: 283px" alt="" hspace=0 src="[\w\d]+\.\w+" border=1>';
    begin
      content := '<IMG style="WIDTH: 400px; HEIGHT: 283px" alt="" hspace=0 src="xinsrc_1020703140958859330618.jpg" border=1>';
      r := TRegExpr.Create;
      try
        r.Expression := pattern;
        if r.Exec(content) then
          repeat
            Result := Result + r.Match[0]; 
          until not r.ExecNext;
      finally
        r.Free;
      end;
    end;
      

  2.   

    多谢 musictom()
    如果我知道他是个图片,不知道其他的属性,该怎么写呢?
    就是没有这些咚咚 ... style="WIDTH: 400px; HEIGHT: 283px" alt="" hspace=0 ...
      

  3.   

    function TForm1.ExtractPictureName;
    var
      content: String;
      r: TRegExpr;
    const
      pattern = '<IMG[\s=";:\d\w]* src="[\w\d]+\.\w+"[\s=";:\d\w]*>';
    begin
      content := '<IMG style="WIDTH: 400px; HEIGHT: 283px" alt="" hspace=0 src="xinsrc_1020703140958859330618.jpg" border=1>';
      r := TRegExpr.Create;
      try
        r.Expression := pattern;
        if r.Exec(content) then
          repeat
            Result := Result + r.Match[0];
          until not r.ExecNext;
        r.Expression := '<IMG[\s=";:\d\w]* src="';
        Result := r.Replace(Result, '', true);
        r.Expression := '[\s=;:\d\w]*>';
        Result := r.Replace(Result, '', true);
        Result := AnsiReplaceText(Result, '"', '');
      finally
        r.Free;
      end;
    end;