1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
type
TStringArray = array of string;
function Explode(chaine: string): TStringArray;
var
i, p, ndx: Integer;
begin
chaine:= Trim(chaine);
SetLength(result, 0);
i:=1; // Le premier caractère d'une chaîne est le numéro 1
p:=1;
ndx:= 0; // Index de la chaine dans le tableau retourné
while i <= Length(chaine) do
begin
if chaine[i] = ' ' then
begin
SetLength(result, Length(result) + 1);
result[ndx]:= Copy(chaine, p, i - p);
p:= i + 1;
Inc(ndx);
end;
Inc(i);
end;
if p <> i then
begin
SetLength(result, Length(result) + 1);
result[ndx]:= Copy(chaine, p, i - p);
end;
end; |
Partager