delphi 分离网址链接最后一层文件目录  
官方Delphi 学习QQ群: 682628230(三千人)
频道

delphi 分离网址链接最后一层文件目录


function ExtractURLName(const S: String): String;
var
  I, L, K1, K2: Integer;
begin
  L := Length(S);

  result := '';

  K1 := 0;
  K2 := 0;

  for I:= L downto 1 do
    if S[I] = '/' then
      if K2 = 0 then
        K2 := I
      else
      begin
        K1 := I;
        result := Copy(S, K1 + 1, K2 - K1 - 1);
        Exit;
      end;
  result := Copy(S, K1 + 1, K2 - K1 - 1);
end;


procedure TForm1.FormCreate(Sender: TObject);
begin
showmessage(ExtractURLName('http://www.delphitop.com/html/zifuchuan/'));     //结果 zifuchuan
end;

推荐分享
图文皆来源于网络,内容仅做公益性分享,版权归原作者所有,如有侵权请告知删除!
 

Copyright © 2014 DelphiW.com 开发 源码 文档 技巧 All Rights Reserved
晋ICP备14006235号-8 晋公网安备 14108102000087号

执行时间: 0.062588930130005 seconds