Tokenize a string: Difference between revisions

→‎{{header|Modula-3}}: Proper version, old version just used 5 for array bounds, this version dynamically allocates the required size.
No edit summary
(→‎{{header|Modula-3}}: Proper version, old version just used 5 for array bounds, this version dynamically allocates the required size.)
Line 341:
IMPORT IO, TextConv;
 
VARTYPE tokens:Texts ARRAY= [1..5]REF ARRAY OF TEXT;
 
VAR tokens: Texts;
string := "Hello,How,Are,You,Today";
sep := SET OF CHAR {','};
 
BEGIN
tokens := NEW(Texts, TextConv.ExplodeExplodedSize("Hello,How,Are,You,Today", tokensstring, sep));
TextConv.Explode(string, tokens^, sep);
FOR i := FIRST(tokens^) TO LAST(tokens^) DO
IO.Put(tokens[i] & ".");
END;
Anonymous user