从字符串右边查找子字符串的位置的函数是什么?(20分)

  • 主题发起人 主题发起人 robert168
  • 开始时间 开始时间
R

robert168

Unregistered / Unconfirmed
GUEST, unregistred user!
如题,谢谢
 
function copyright(const as:string;acount:integer)
begin
result:=Copy(as,Length(as)-acount,length(as))
end;
 
delphi直接只提供从左边的, 非要右边的话就像楼上那样

左撇子和右撇子用的筷子总不能分别生产吧
 
unit StrUtilsl;
righrstr('6tryuttuty',3)
得到:‘uty’
 
楼上的 把StrUtilsl.pas贴上来撒 , 不然咋整
 
来自:99134234, 时间:2006-11-16 13:09:03, ID:3624622
楼上的 把StrUtilsl.pas贴上来撒 , 不然咋整


楼上滴 正NB

StrUtilsl.pas 系统自带滴 贴个P阿
 
楼主好象要返回子串的位置,而不是子串吧[:D]

//返回0值表示未找到
function RightPos(substring, s: string);
begin
result:=0;
for i:= length(s) down to 1 do
begin
if s:= substring then result:=i;
//如果自左算起则 result:= length(s) - i;
end;
end;
 
for i:=0 to length(str)-1 do
begin
if str='你要查找的字' then
begin
//i 就是你要的数
end;
end;
 
后退
顶部