请问如何在一段字符串中提取特定的子字符串,
例如:
在<html>
......
.....
<table> 
...
...
</table>
...
</html>
中只提取
<table> 
...
...
</table>
这个部分

解决方案 »

  1.   

    可以考虑用TSTRINGLIST
    LOADFROM() ;
    IndexOf()
      

  2.   

    a := Pos('<table>',s);
    b := Pos('</table>,s);
    if (a=0) or (b=0) then Result := ''
    else
    begin
      a := a + Length('<table>';
      Result := Copy(s,a,b-a);
    end;
      

  3.   

    1  s 赋值没有?
    2  s 中是否有<table>和</table>,大小写是否匹配
    3  如果是<table ...>,就要修改一下代码,自己改吧
      

  4.   

    zfmich() 的方法不错,我就是用这个方法汉化Delphi的资源字符串的,好使!
      

  5.   

    function GetTable(a : string): string;
    begin
      if (pos('<table>',a)<>0) and (pos('</table>',a)<>0) then
        result := copy(a,pos('<table>',a),pos('</table>',a)-pos('<table>',a)+8)
      else
        result := '';
    end;