Already several times, without this function or feel very inconvenient, so I wrote a:
functionLastpos (strfind:string; ch:char): integer;varI, N:integer;beginResult:= -1; ifStrfind="' Then beginExit; End; fori:=0 toLength (Strfind) Do begin ifStrfind[i]=ch ThenResult:=i; End;End;procedureTform1.button1click (sender:tobject);vars1:string;beginS1:='ABC'; ShowMessage (s1[1]); ShowMessage (IntToStr (Length ('/myaccount/save1/'))); ShowMessage (IntToStr (Lastpos ('/myaccount/save1/','/')));End;
Of course, there are no issues such as efficiency and Unicode, which are better for D7 anyway.
Another algorithm, see how others write it (reverse is not normal thinking):
function Lastpos (conststring; C:char): Integer; var I:integer; begin i:= Length (S); while 0 and Do Dec (i); Result:= i; End;
Self-written lastpos, looking for the last character in the string, the RTL does not provide this function--delphi string subscript is starting from 1