Logo

Programming-Idioms

History of Idiom 49 > diff from v19 to v20

Edit summary for version 20 by :
[Pascal] Fixed everything

Version 19

2016-02-07, 17:39:29

Version 20

2016-02-07, 21:17:28

Idiom #49 Split a space-separated string

Build list chunks consisting in substrings of input string s, separated by one or more space characters.

Idiom #49 Split a space-separated string

Build list chunks consisting in substrings of input string s, separated by one or more space characters.

Imports
Uses Classes;
Imports
Uses Classes;
Code
var
  SL: TstringList;
begin
  //assume the list is created (and freed at some later point)
  SL.StrictDelimiter := True;
  SL.Delimiter := #32; //#32 is space char
  SL.DelimitedText := 'Text containing several spaces   !';
end; 
Code
chunks.StrictDelimiter := True;
chunks.Delimiter := ' ';
chunks.DelimitedText := s;
Comments bubble
chunks has type TstringList.