先确定'_'的位置m,然后向前搜索直到不是3的止(位置n) 可以通过copy()函数获取。function getstr(scrstr:string):string; var n,m:integer; tempstr:string; begin m:=pos('_',scrstr); if m>1 then begin n:=m-1; while copy(scrstr,n,1)=3 and n>0 do n:=n-1; result:=copy(scrstr,n+1,m-n-1); end else result:=''; end;
可以通过copy()函数获取。function getstr(scrstr:string):string;
var
n,m:integer;
tempstr:string;
begin
m:=pos('_',scrstr);
if m>1 then
begin
n:=m-1;
while copy(scrstr,n,1)=3 and n>0 do
n:=n-1;
result:=copy(scrstr,n+1,m-n-1);
end
else
result:='';
end;