如何获取字符串中左边,或右边的字符? 我要获取字符串中左边,或右边的字符,可采用哪些函数?能否给出一些具体的用法?Thank you! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 copy(字符串,起始位置,长度) uses StrUtils;LeftStr('Hello', 2) // 'He'RightStr('Hello', 2) // 'lo' 在uses单元中引用StrUtils;LeftStr('abc',1);//返回'a'RightStr('abc',1);//返回'c' 由于我的程序可能较大,哪种方法耗资源较少?我只取左边A:copy(字符串,起始位置,长度)B:LeftStr 那就直接用Copy吧,少一层调用。LeftStr和RightStr都是用Copy实现的:{ StrUtils.pas }function LeftStr(const AText: string; const ACount: Integer): string;begin Result := Copy(AText, 1, ACount);end;function RightStr(const AText: string; const ACount: Integer): string;begin Result := Copy(AText, Length(AText) + 1 - ACount, ACount);end; uses StrUtils;左LeftStr右RightStr中间的MidStrCopy也OK,但没那么简单 DELPHIXE2在WINXP下能否开发共享对象库(.SO文件)? TList如何实现这样的数据结构 一个问题,请高手指点哦! delpihi调用其他窗体变量 想问一下在delphi7里怎样实现自动发邮件的功能 关于音量控制的问题,请知道的朋友帮帮忙,不知道的朋友帮着顶一下,感谢! sql语句查询 高手请进:关于IE打印的问题 如何将一个新增的Form作为MDI Form的Child? Sql7.0问题100分 关于deletefile() 求助~~急`~关于dbgrid
RightStr('Hello', 2) // 'lo'
RightStr('abc',1);//返回'c'
A:copy(字符串,起始位置,长度)
B:LeftStr
{ StrUtils.pas }
function LeftStr(const AText: string; const ACount: Integer): string;
begin
Result := Copy(AText, 1, ACount);
end;function RightStr(const AText: string; const ACount: Integer): string;
begin
Result := Copy(AText, Length(AText) + 1 - ACount, ACount);
end;
右RightStr
中间的MidStrCopy也OK,但没那么简单