字符串中取数字, function findNUM(s:string):string; begin begin date:=' '; for i:=1 to length(s) do begin if (s[i]>='0')and(s[i]<='9') then date:=date+s[i]; end; end;
同意,你首先取得文件名,然后通过 . 来pos 左便的 文件名,不要后缀名就行了
用lincanwen(密码错误)的吧,其他人有误导之嫌。
function retuFileName(const FileName: string): string; var I: Integer; begin I := LastDelimiter(PathDelim + DriveDelim, FileName); Result := Copy(FileName, 1, MaxInt-i-1); end;
不好意思?上面的写错了。如下 function retuFileName(const FileName: string): string; var I: Integer; begin I := LastDelimiter('.', FileName); Result := Copy(FileName, 1, i-1);end;
copy('340121790926373.jpg',0,pos('.','340121790926373.jpg'));就好了
begin
Result:= Copy(str, 1, Pos(ch, str)-1)
end;function CopyStrRight(ch: Char; str: string): string;
begin
Result:= Copy(str, Pos(ch, str)+1, Length(str)-Pos(Ch, str)+1)
end;
begin
str:='340121790926373.jpg';
showmessage(Copy(Str,1,Pos(ExtractFileExt(str),Str) - 1));
end;
sRes,str: string;str := '340121790926373.jpg';
sRes := copy(str,1,pos('.',str) -1 );
应该是从1开始的啊,是DELPHI啊
copy('340121790926373.jpg',1,pos('.','340121790926373.jpg')-1)
或者
copy('340121790926373.jpg',1,length('340121790926373.jpg') - 4)
i:=Pos('.',s);
delete(s,i,Length(s)-i+1)
i:=Pos('.',s);
delete(s,i,Length(s)-i+1)
function findNUM(s:string):string;
begin
begin
date:=' ';
for i:=1 to length(s) do
begin if (s[i]>='0')and(s[i]<='9')
then
date:=date+s[i];
end;
end;
var
I: Integer;
begin
I := LastDelimiter(PathDelim + DriveDelim, FileName);
Result := Copy(FileName, 1, MaxInt-i-1);
end;
function retuFileName(const FileName: string): string;
var
I: Integer;
begin
I := LastDelimiter('.', FileName);
Result := Copy(FileName, 1, i-1);end;
copy('340121790926373.jpg',0,pos('.','340121790926373.jpg')-1);就好了