Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function StrExplode(d: Char; str: string): TStringArray;
- var
- i, l, r, q, c, s: Integer;
- begin
- SetLength(Result, 1);
- l := Length(str);
- if (l > 0) then
- begin
- r := 0;
- q := 1;
- i := 0;
- s := 1;
- c := 0;
- repeat
- i := (i + 1);
- if (str[i] = d) then
- begin
- if (c > 0) then
- Result[r] := Copy(str, s, (c + 1));
- r := (r + 1);
- if (q <= r) then
- begin
- q := (q + q);
- SetLength(Result, q);
- end;
- s := (i + 1);
- c := 0;
- end else
- c := (c + 1);
- until (i = l);
- if (c > 0) then
- Result[r] := Copy(str, s, (c + 1));
- SetLength(Result, (r + 1));
- end else
- Result[0] := str;
- end;
- function StrExplode2(d: Char; str: string): TStringArray;
- var
- i, l, r, c, s: Integer;
- begin
- SetLength(Result, 1);
- l := Length(str);
- if (l > 0) then
- begin
- r := 0;
- i := 0;
- s := 1;
- c := 0;
- repeat
- i := (i + 1);
- if (str[i] = d) then
- begin
- if (c > 0) then
- Result[r] := Copy(str, s, (c + 1));
- r := (r + 1);
- SetLength(Result, (r + 1));
- s := (i + 1);
- c := 0;
- end else
- c := (c + 1);
- until (i = l);
- if (c > 0) then
- Result[r] := Copy(str, s, (c + 1));
- end else
- Result[0] := str;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement