Recent

Author Topic: TStringList.ExtractStrings doesn't return empty columns  (Read 3814 times)

krzynio

  • Jr. Member
  • **
  • Posts: 99
    • Krzynio's home page
TStringList.ExtractStrings doesn't return empty columns
« on: September 11, 2017, 04:44:03 pm »
I use ExtractStrings for parsing a line of text in csv format.
Generally works fine but when a column is empty ExtractStrings doesn't return empty string but next value and number of returned items is reduced.
I.E. the string: 123,456,,,789 will return only 3 items instead of 5.
Ubuntu 23.10 x64, / Windows 11 PL - latest updates
Lazarus 2.2.6, FPC 3.2.2

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: TStringList.ExtractStrings doesn't return empty columns
« Reply #1 on: September 11, 2017, 04:50:05 pm »
I haven't checked but have you set AddEmptyStrings parameter to true ?

Ive checked (those online compilers are a bless) Seems indeed to work as expected,
Code: [Select]
  retval := ExtractStrings([','], [], '123,456,,,789', SL, true);
retval = 5, and SL.Count = 5;
« Last Edit: September 11, 2017, 05:14:05 pm by molly »

 

TinyPortal © 2005-2018