Do I need to parse strings from a TStringStream using a substring delimiter in Delphi?

Using Delphi XE, I need to parse a TStringStream into strings bounded by a string. The separator string in one case will be [eol]. The stream is downloaded from the web server using indy IdHttp.

Then I need to parse the lines from the stream, and they are separated by the string "[eol]". As an example, a StringStream may contain:

"12345 [eol] this is] something [eol] and [this is nothing [eol] etc. [etcetc [[eol]"

should analyze:

"12345"

"It is something"

"and [it's nothing"

"etc. [etcetc ["

Most limiter methods that I know use only separate character delimiters, and then I also need to iterate over the entire stream to the end. I'm at a loss

+3
1

Indy, SplitColumnsNoTrim() String TStrings String, . , SplitColumnsNoTrim() . , SplitColumns() .

var
  Strm: TStringStream;
  Strings: TStringList;
begin
  Strings := TStringList.Create;
  try
    Strm := TStringStream.Create;
    try
      IdHTTP.Get('http://...', Strm);
      SplitColumnsNoTrim(Strm.DataString, Strings, '[eol]'); 
    finally
      Strm.Free;
    end;
    // use Strings as needed ...
  finally
    Strings.Free;
  end;
end;

TStringStream . TStringStream D2009 + TEncoding ( Ansi ), , TIdHTTP TStringStream. , ASCII. TIdHTTP String , , :

var
  Strings: TStringList;
begin
  Strings := TStringList.Create;
  try
    SplitColumnsNoTrim(IdHTTP.Get('http://...'), Strings, '[eol]'); 
    // use Strings as needed ...
  finally
    Strings.Free;
  end;
end;
+4

All Articles