fork(6) download
  1. var
  2. c : Char;
  3. s : String =
  4. '[123, 2345, ''test'', ''str1, str2'', -1234, ''str3 ''is'' str4'']';
  5. Chunks : Integer = 1;
  6. Quotes : Boolean = true;
  7.  
  8. begin Writeln(s);
  9. for c in s do case c of
  10. '''': Quotes := not Quotes;
  11. ',': if Quotes then inc(Chunks)
  12. end;
  13. Writeln('Chunks = ', Chunks); Readln
  14. end.
Success #stdin #stdout 0s 276KB
stdin
Standard input is empty
stdout
[123, 2345, 'test', 'str1, str2', -1234, 'str3 'is' str4']
Chunks = 6