I'm trying to parse a string with a TStringList
:
sl:=TStringList.Create;
try
sl.Text:=aString;
FFirstRow:=sl[0];
FSecondRow:=sl[1];
finally
sl.Free;
end;
If aString:='aa'+#13#10+'bb'
or aString:='aa'+sLineBreak+'bb'
then FFirstRow
is aa
and FSecondRow
is bb
. But if aString:='aa\nbb'
then FFirstRow
gets the whole string (and there is no second row). How do I parse the string with \n
as a delimiter?
I tried sl.Delimiter:=Char(13)
(and sl.DelimitedText:=aString
).
.Delimiter
is one character and not a String (\n
are two characters) you can't. But what keeps you from replacing all\n
occurrances with#13#10
before? – AmigoJack