
Originally Posted by
i luffs yeww
That's not all the possibilities, Dg. What about "dgro" or "dgroc" or "dgrock" or "dgrocks" or "dgrocks?" etc. There are a lot of possible combinations with this.
Ah.... Hm.... I got mislead from the box example =( Ill go back to the drawing board...
Edit: Ok I've got this.... Tho I don't like how I got the Length of Result I think there is a better way.
Simba Code:
program StringSplit;
function SplitString(str: string): TStringArray;
var
L, K, I, J, H, M: integer;
SA: TStringArray;
begin
str := Trim(str);
L := Length(str);
K := 0;
J := 0;
SA := Explode(' ', str);
for I := Low(SA) to High(SA) do
for M := 0 to Length(SA[I]) - 1 do
IncEx(J, Length(SA[I]) - M);
SetArrayLength(Result, J);
for I := 1 to L do
begin
if (str[I] = ' ') then
Continue;
Result[K] := str[I];
for J := I + 1 to L do
begin
if (str[J] = ' ') then
break;
Inc(K);
Result[K] := '';
for H := I to J do
Result[K] := Result[K] + str[H]
end;
Inc(K);
end;
end;
begin
WriteLn(SplitString('Dgby714 Rocks!'));
end.
Output:
Code:
['D', 'Dg', 'Dgb', 'Dgby', 'Dgby7', 'Dgby71', 'Dgby714', 'g', 'gb', 'gby', 'gby7', 'gby71', 'gby714', 'b', 'by', 'by7', 'by71', 'by714', 'y', 'y7', 'y71', 'y714', '7', '71', '714', '1', '14', '4', 'R', 'Ro', 'Roc', 'Rock', 'Rocks', 'Rocks!', 'o', 'oc', 'ock', 'ocks', 'ocks!', 'c', 'ck', 'cks', 'cks!', 'k', 'ks', 'ks!', 's', 's!', '!']