![]() |
Implode / Explodetype TExplodeArray = array of String; {...} function Implode(const cSeparator: String; const cArray: TExplodeArray): String; var i: Integer; begin Result := ''; for i := 0 to Length(cArray) -1 do begin Result := Result + cSeparator + cArray[i]; end; System.Delete(Result, 1, Length(cSeparator)); end; function Explode(const cSeparator, vString: String): TExplodeArray; var i: Integer; S: String; begin S := vString; SetLength(Result, 0); i := 0; while Pos(cSeparator, S) > 0 do begin SetLength(Result, Length(Result) +1); Result[i] := Copy(S, 1, Pos(cSeparator, S) -1); Inc(i); S := Copy(S, Pos(cSeparator, S) + Length(cSeparator), Length(S)); end; SetLength(Result, Length(Result) +1); Result[i] := Copy(S, 1, Length(S)); end;Источник |