[fpc-pascal] ExtractStrings skips empty string parts?

silvioprog silvioprog at gmail.com
Sun Jan 26 03:54:52 CET 2014


Hello,

Conforms issue #16043:

"ExtractStrings in the Classes unit skips over empty text. For example:

"AAA,BBB,,CCC"

is converted to:

"AAA"
"BBB"
"CCC"

I was expecting:

"AAA"
"BBB"
""
"CCC"

Is this the intended behavior, or is it a bug?".

So, if I try:

procedure TForm1.Button1Click(Sender: TObject);
var
  s: TStringList;
begin
  s := TStringList.Create;
  try
    s.StrictDelimiter := True;
    s.Delimiter := '|';
    ExtractStrings(['|'], [], 'A|B||C', s);
    ShowMessage(IntToStr(s.Count));
  finally
    s.Free;
  end;
end;

It returns 3. But, if I try:

procedure TForm1.Button2Click(Sender: TObject);
var
  s: TStringList;
begin
  s := TStringList.Create;
  try
    s.StrictDelimiter := True;
    s.Delimiter := '|';
    s.DelimitedText := 'A|B||C';
    ShowMessage(IntToStr(s.Count));
  finally
    s.Free;
  end;
end;

It returns 4.

How to configure ExtractStrings to works without skip empty strings like
DelimitedText?

Thank you!

-- 
Silvio Clécio
My public projects - github.com/silvioprog
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20140126/2a925f45/attachment.html>


More information about the fpc-pascal mailing list