字符串怎样从后面截取?比如'C:\abc\ded\123.txt',怎样取123

解决方案 »

  1.   

    Copy(str,length(str),length你想截的长度)
      

  2.   

    pos不可以么?
    如果一定倒着来:比如 189212397234978932123789 先定位后面的123
    nowstr:=onestr;
    snowstr:=sonestr;
    for i:=0 to length(nowstr)-1 do
    begin
     nowstr[i]:=onestr[length(onestr)-1-i]
    end;
    for i:=0 to length(soneset)-1 do
    begin
     snowstr[i]:=onestr[length(sonestr)-1-i]
    end;
     i:= pos(snowstr,nowstr)
      

  3.   

    strPath := 'C:\abc\ded\123.txt';
    strFile := ExtractFileName(strPath);
    iPos := Pos('.',strFile);
    Delete(strFile,iPos,Length(strFile)-iPos+1);Now: strFile Is THE STRING YOU WANT!