StrSplit for Delphi
As I did not quite manage to split a string through assigning a value to TStringList.DelimitedText, I figured out the following funtion to split a string into a TStringList using a custom delimiter.
function StrSplit(const Input: String; Delimiter: Char): TStringList;
begin
Result := TStringList.Create;
ExtractStrings([Delimiter], [], PChar(Input), Result);
end;
begin
Result := TStringList.Create;
ExtractStrings([Delimiter], [], PChar(Input), Result);
end;
Parsed in 0.021 seconds, using GeSHi © 2005 Nigel McNie
Dont't forget to add the Classes unit to your uses clause.
Last edited by Ingmar on Wednesday, July 19th 2006 00:09:00 CEST


