//把phaler(phaler)的该一下就可以了 function PickStr(Value: string): string; begin result:= Trim(Copy(Value, 1, Pos('[', Value) - 1)); end;
var I: integer; str: string; index: integer; begin str := 02 [root]; for I := 0 to length(str)-1 do begin if (str[I] = ' ') and (index = 0) then begin index := I; end else if (str[I] = ' ') and (index > 0) then begin exit; end; end; result := copy(str,0,index - 1 ); //结果; end;
‘02’这个串为不固定的宽度
begin
result:= Trim(Copy(Value, 1, Pos('[root]', Value) - 1));
end;
这个不定,那个不定,总得有点规律吧?没有规律是做不了的。
只要有规律,用phaler(phaler) 的方法就基本可以搞定了。
function PickStr(Value: string): string;
begin
result:= Trim(Copy(Value, 1, Pos('[', Value) - 1));
end;
str: string;
index: integer;
begin
str := 02 [root];
for I := 0 to length(str)-1 do
begin
if (str[I] = ' ') and (index = 0) then
begin
index := I;
end
else if (str[I] = ' ') and (index > 0) then
begin
exit;
end;
end; result := copy(str,0,index - 1 ); //结果;
end;