起步软件技术论坛-X3

 找回密码
 立即注册
搜索
查看: 258|回复: 3

【结贴】字符串截取问题

[复制链接]
发表于 2009-9-8 14:42:25 | 显示全部楼层 |阅读模式
http://bbs.justep.com/forum.php? ... ghlight=LastIndexOf
和这个帖子中同样的问题。
                  if length(temp)<=35 then
                      begin
                         str1 := temp.Substring(0,length(temp));
                         temp:='';
                      end else
                     begin
                        if  temp.Substring(0,35).LastIndexOf(',')>0  then  str1:=temp.Substring(0,str1.LastIndexOf(',')+1) else
                        if  temp.Substring(0,35).LastIndexOf(' ')>0  then  str1:=temp.Substring(0,str1.LastIndexOf(' ')+1) else str1:=temp.Substring(0,35);
                            temp:= temp.Substring(length(str1)-1,length(temp)-length(str1));
                     end;
同样报地址错误;版本3.0.6.2800
回复

使用道具 举报

 楼主| 发表于 2009-9-8 14:44:46 | 显示全部楼层
急!换成IndexOf没有报错。
回复 支持 反对

使用道具 举报

发表于 2009-9-8 16:52:16 | 显示全部楼层
嗯,是缺陷
回复 支持 反对

使用道具 举报

 楼主| 发表于 2009-9-9 09:21:42 | 显示全部楼层
结贴吧,用IndexOf循环做了,如果是LastIndexOf会方便很多。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Justep Inc.

GMT+8, 2025-7-16 07:33 , Processed in 0.041917 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表