SHOW:
|
|
- or go back to the newest paste.
| 1 | uses Types; | |
| 2 | ||
| 3 | function SplitStr(const Str: string; const Delimiter: string): TStringDynArray; | |
| 4 | var | |
| 5 | L : Integer; | |
| 6 | I : Integer; | |
| 7 | S : Integer; | |
| 8 | D : Integer; | |
| 9 | A : Integer; | |
| 10 | begin | |
| 11 | L := Length(Str); | |
| 12 | S := 1; | |
| 13 | D := Length(Delimiter); | |
| 14 | I := 1; | |
| 15 | A := 0; | |
| 16 | - | begin |
| 16 | + | |
| 17 | if Copy(Str, I, D) = delimiter then | |
| 18 | begin | |
| 19 | - | A := Length(Result); |
| 19 | + | |
| 20 | Result[A] := Copy(Str, S, I - S); | |
| 21 | S := I + D; | |
| 22 | Inc(I, D); | |
| 23 | Inc(A); | |
| 24 | end | |
| 25 | else | |
| 26 | Inc(I); | |
| 27 | - | end; |
| 27 | + | |
| 28 | A := Length(Result); | |
| 29 | SetLength(Result, A + 1); | |
| 30 | Result[A] := Copy(Str, S, L-S+1); | |
| 31 | - | Result[A] := Copy(Str, S, L-S); |
| 31 | + |