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;

相关阅读 >>

Delphi vcl图像的二值化

Delphi ado的事务处理例子

Delphi获取其他进程中状态栏文本的函数

Delphi整理五(枚举、子界、集合)

download 和 http downloader 源码

Delphi fmx输出彩色文本

Delphi中使用isuperobject解析json数据

Delphi替换字符串中的单引号

Delphi cxgrid 通过字段名取得列

Delphixe 如何调用stringtojstring

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...