0 Members and 2 Guests are viewing this topic.
function IXSplit(const SOURCE: string; Delimiter: string): array of string;var i, x, d: integer; s, b: string;begin d:= length(Delimiter); i:= 1; SetArrayLength(Result, 0); while (i <= length(SOURCE)) do begin s:= Copy(SOURCE, i, d); if (s = Delimiter) then begin SetArrayLength(Result, x + 1); Result[x]:= b; Inc(i, d); Inc(x, 1); b:= ''; end else begin b:= b + Copy(s, 1, 1); Inc(i, 1); end; end; if (b <> '') then begin SetArrayLength(Result, x + 1); Result[x]:= b; end;end;
SOURCE: array of stringArray of string to be splitted into an array of string.
function Explode(source, delim: string): array of string;begin source := source + delim; while strpos(delim, source) <> 0 do begin SetArrayLength(Result, GetArrayLength(Result) + 1); Result[GetArrayLength(Result) - 1] := copy(source, 0, strpos(delim, source)); source := copy(source, strpos(delim, source) + 1, length(source)); end;end;
Quote from: Markus Quär on February 08, 2009, 05:52:09 amSOURCE: array of stringArray of string to be splitted into an array of string.ORLY?
Code: [Select]function Explode(source, delim: string): array of string;begin source := source + delim; while strpos(delim, source) <> 0 do begin SetArrayLength(Result, GetArrayLength(Result) + 1); Result[GetArrayLength(Result) - 1] := copy(source, 0, strpos(delim, source)); source := copy(source, strpos(delim, source) + 1, length(source)); end;end;