现成函数,直接调用即可:
function GetFirstBetweenTwoSpaceStr(OldStr:string):String;
var
I,J:Integer;
TempStr:Array[1..255] of char;
begin
Flag:Boolean;
EndFlag:Boolean;
begin
I:=1;
//定位到第一个空格处
while(OldStr<>' ') and (I<length(OldStr))do
begin
I:=I+1;
end;
//如果串中无空格,则返回空串
if I=length(OldStr) then
begin
Result:='';
exit;
end;
//为串赋值
J:=I;
I:=I+1;
while (OldStr<>' ') and (I<=length(OldStr))do
begin
TempStr[I-J]:=OldStr;
I:=I+1;
end;
result:=TempStr;
end;