求一个提取url字符串当中最后一个“/”后面的字符串,也就是页面文件名称。

cdsun 2006-04-05 05:50:53
假设url是不固定的
有可能是
http://192.168.1.100/111/11.rar
http://192.168.1.100/222/22/22.rar
http://192.168.1.100/333/333/333/333/333/33/33/33.rar


怎么能用一个函数来固定的能够提取到比如11.rar/22.rar/33.rar文件名

对delphi不太熟悉
我想的是先替换http://之后在从右往左减去/之前的内容一个一个减最后替换掉/就是了

但是不知道具体该怎么写
谁能帮助一下,在线等待。
...全文
377 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
hellolongbin 2006-04-10
  • 打赏
  • 举报
回复
cdsun 2006-04-07
  • 打赏
  • 举报
回复
楼上的说的什么阿
hellolongbin 2006-04-06
  • 打赏
  • 举报
回复
Delphi syntax:

function LastDelimiter(const Delimiters, S: string): Integer;

Description

Call LastDelimiter to locate the last delimiter in a specified string.

Delimiters is a string where each character is a valid delimiter.

S is the string to search for delimiters.

For example, the line

MyIndex := LastDelimiter('\.:','c:\filename.ext'); // Delphi

MyIndex = LastDelimiter("\\.:","c:\\filename.ext"); // C++

sets MyIndex to 12.

When working with multi-byte character sets (MBCS), S may contain double byte characters, but the delimiters listed in the Delimiters parameter must all be single byte non-null characters.
hellolongbin 2006-04-06
  • 打赏
  • 举报
回复
有个函数叫LastDelimiter
pathletboy 2006-04-05
  • 打赏
  • 举报
回复
转换函数
function convert(input:string):string;
var
i:integer;
c:pchar;
begin
c:=pchar(input);
for i:=length(input) downto 0 do begin
if c[i]='/' then break;
end;
convert:=copy(input,i+2,length(input));
end;
todouwang 2006-04-05
  • 打赏
  • 举报
回复
function TForm1.funGetCurrentDir(const str: string): string;
var i: integer;
begin
for i := length(str) - 1 downto 0 do
begin
if str[i] = '\' then
break;
end;
Result := copy(str, 0, i - 1);
end;
cdsun 2006-04-05
  • 打赏
  • 举报
回复
有没有人帮帮忙阿
cdsun 2006-04-05
  • 打赏
  • 举报
回复
道理我也明白
但是怎么具体写能不能告诉我
我不太熟悉delphi的语法
wing_er 2006-04-05
  • 打赏
  • 举报
回复
从右向左
wing_er 2006-04-05
  • 打赏
  • 举报
回复
从左向右找第一个'/'
然后区后面的部分

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧