sloppycode.net
String splitting
Splits a string into a list
Home
›
Code snippets
›
Delphi
›
String splitting
A very basic function that splits a string into a TStringList using the character provided,e.g. for a CSV file you would use ','
function ClassName.split(seperator: Char; text: String; var list: TStringList): Integer; var mypos, number: Integer; begin number:=0; if Length(text) > 0 then begin if text[Length(text)] <> seperator then text:=text+seperator; while(Pos(String(seperator),text))>0 do begin mypos:=Pos(String(seperator),text); list.Add(Copy(text,1,mypos-1)); text:=Copy(text,mypos+1,Length(text)-mypos); Inc(number); end; end; Result:=number; end;
{Name}
Says:
{Date}
{Text}
› Home
› C#
› Snippets
› Articles
› Tools
› Taglines
› ASP
› Dictionary Object
› FSO
› Unix cheat sheet
› Gaming
› CSS
› Yak
› Umbraco
› About
› Contact
› Privacy
› Projects
› Search
› Sitemap
Buy on Amazon
Buy on Amazon
Buy on Amazon
Buy on Amazon