Function Jmsczb(s:string):string
var mstr,mtempstr,mriqi,mno:string; i:integer;
begin
result:='';
if trim(s)='' then exit;
mstr:=trim(s);
for i:=1 to length(mstr) do
if mstr in [0..9] then
mtempstr:=mtempstr+mstr
else begin
mstr:=copy(mstr,i+1,255);
break;
end;
//mtempstr 为时间
//如果时间格式为2001112 则无法分别应该为 2001-1-12 还是 2001-11-2 本函数取 2001-11-2
case length(mtempstr) of
8: mriqi:=mtempstr; //*****yyyymmdd
7: begin
if strtoint(copy(mtemstr,5,2))>12 then
mriqi:=copy(mtempstr,1,4)+'0'+copy(mtempstr,5,3) //yyyymdd
else mriqi:=copy(mtempstr,1,4)+copy(mtempstr,5,2)+'0'+copy(mtempstr,7,1); //yyyymmd
end; //*****yyyymdd or yyyymmd
6: begin
if (copy(mtempstr,1,2)<>'19') and (copy(mtempstr,1,2)<>'20') then begin //yymmdd
if strtoint(copy(mtempstr,1,2))<50 then
mriqi:='20'+copy(mtempstr,1,2)+copy(mtempstr,3,2)+'0'+copy(mtempstr,5,2) //yy<50 then yyyy=20yy
else mriqi:='19'+copy(mtempstr,1,2)+copy(mtempstr,3,2)+'0'+copy(mtempstr,5,2); //else yyyy=19yy
end else
mriqi:=copy(mtempstr,1,4)+'0'+copy(mtempstr,5,1)+'0'+copy(mtempstr,6,1); //yyyymd
end; //*****yyyymd or yymmdd
5: begin
if strtoint(copy(mtempstr,1,2))<50 then
mriqi:='20'+copy(mtempstr,1,2) //yy<50 then yyyy=20yy
else mriqi:='19'+copy(mtempstr,1,2); //else yyyy=19yy
if strtoint(copy(mtemstr,3,2))>12 then
mriqi:=mriqi+'0'+copy(mtempstr,3,3) //yymdd
else mriqi:=mrqi+copy(mtempstr,3,2)+'0'+copy(mtempstr,5,1); //yymmd
end; //*****yymmd or yymdd
4: begin
if strtoint(copy(mtempstr,1,2))<50 then
mriqi:='20'+copy(mtempstr,1,2) //yy<50 then yyyy=20yy
else mriqi:='19'+copy(mtempstr,1,2); //else yyyy=19yy
mriqi:=mrqi+'0'+copy(mtempstr,3,1)+'0'+copy(mtempstr,4,1);
end; //*****yymd
else mriqi='00000000';
end;
//日期取出完毕
//取出流水号
mtempstr:='';
for i:=length(mstr) downto 1 do
if mstr not in [0..9] then begin
mstr:=copy(mstr,1,i-1);
exit;
end else mtempstr:=mstr+mtempstr;
mno:=mtempstr;
//取出流水号完毕
//忽略大小写全部替换,可能会存在将不该替换的替换,进一步控制可以从后向前替换,在此略过。
mtempstr:=mstr;
StringReplace(mtempstr,'IE','海运',[rfReplaceAll,rfIgnoreCase]);
StringReplace(mtempstr,'','',[rfReplaceAll,rfIgnoreCase]); //如上略过
StringReplace(mtempstr,'','',[rfReplaceAll,rfIgnoreCase]);
StringReplace(mtempstr,'','',[rfReplaceAll,rfIgnoreCase]);
StringReplace(mtempstr,'','',[rfReplaceAll,rfIgnoreCase]);
result:=mriqi+mtempstr+mno;
end;