比如有字符串 s := 'c:\asd\asd\aaa.txt' 怎样可以得到 s 的 substring := 'aaa.txt'
请给出上例的具体代码 谢谢~~~~~~~~~~
请给出上例的具体代码 谢谢~~~~~~~~~~
解决方案 »
- grid问题
- 在pagefooter里用[SUM(<frxDBDataset."总额">,MasterData1)],为何打印预览无显示
- ODAC连接oracle用net方式,程序编译后直接发布出错
- 如何向注册表中写入二进制数值。
- 初学Delphi,请问5、6、7各个版本有什么区别?
- 这样的程序如何编,谁有好思路,回复均有分...
- 请大家看一下这段程序,帮我改一下,谢谢
- 新手问题,在线等待。。。。。。
- 如何在自己程序结束时关闭外部程序
- Delphi 如何对表格表头拖拽(或者说,如何接管、监听表头的Header的拖拽动作?)?
- 请为新手推荐一下delphi的图书吧,谢谢了
- fastreport 定义 b: TfrBandView;中 b.SetBounds(0, 20, 0, 20);怎么宽度为0 啊?
var
i, j, k: integer;
begin
result := '';
if po < 1 then
exit;
s_str := trim(s_str) + d_str;
i := 0;
while 1 = 1 do
begin
if pos(d_str, s_str) > 0 then
begin
j := pos(d_str, s_str) + length(d_str);
k := length(s_str) - (j - 1);
i := i + 1;
if i = po then
begin
j := pos(d_str, s_str);
result := copy(s_str, 1, j - 1);
break;
end;
s_str := copy(s_str, j, k);
end
else
break;
end;
end;
那可以用substring :=stringreplace(s,'aaa.txt' ,'aaa.txt' [fignorecase]);
a:integer;
--用a:=function Pos(Substr: string; S: string): Integer;循环判断s中是否有\,
--如果有令s为s:=copy(s,a,len(s)-a),一直到字符串中没有'\'为止.
用copy(s,a,len(s)-a),
substring := ExtractFileName(s);
如果取文件路径用extractfilepath('c:\asd\asd\aaa.txt' );