132
|
1 /*******************************************************************************
|
|
2
|
|
3 Tokenize input from the console. There are a variety of handy
|
|
4 tokenizers in the tango.text package ~ this illustrates usage
|
|
5 of an iterator that recognizes quoted-strings within an input
|
|
6 array, and splits elements on a provided set of delimiters
|
|
7
|
|
8 *******************************************************************************/
|
|
9
|
|
10 import tango.io.Console;
|
|
11
|
|
12 import Text = tango.text.Util;
|
|
13
|
|
14 void main()
|
|
15 {
|
|
16 // flush the console output, since we have no newline present
|
|
17 Cout ("Please enter some space-separated tokens: ") ();
|
|
18
|
|
19 // create quote-aware iterator for handling space-delimited
|
|
20 // tokens from the console input
|
|
21 foreach (element; Text.quotes (Text.trim(Cin.get), " \t"))
|
|
22 Cout ("<") (element) ("> ");
|
|
23
|
|
24 Cout.newline;
|
|
25 }
|