Split String 1

If you want to split string from TStringList you can use this little code.

procedure Split(const str1:string; const sep:string; LT:TStringList);
var
i:Integer; {Holds the Real Pos}
t:AnsiString; {Holds the String}
i2:integer; {Holds the second pos}
begin
i:=1;
t:=str1;
repeat
t:=AnsiRightStr(t,Length(t)-i-Length(sep)+1);{Gets the right of the the string at the pos of the separator}
i:=AnsiPos (sep,t);{Gets the pos(Holds it)}
i2:=AnsiPos(sep,t); {The real pos(USes it)}
if AnsiLeftStr(t,i2-1)= ” then {Checks if the string is empty}
begin{Do nothing if is}
end
else
begin
LT.Add(AnsiLeftStr(t,i2-1)); {Adds to the TStringList}
end;
until i=0;{^Does above until the no more seperators}
end;

Incoming search terms:

  • delphi split string
  • delphi split
  • split delphi
  • splitstring delphi
  • split string delphi
  • delphi splitstring
  • split delphi uses
  • parse string delphi
  • split in delphi
  • split string delphi without stringlist
This entry was posted in Strings. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Please copy the string eLtZ14 to the field below: