Download Reference Manual
The Developer's Library for D
About Wiki Forums Source Search Contact

Changes from Version 1 of TokenExample

Show
Ignore:
Author:
kris (IP: 68.122.193.31)
Timestamp:
04/17/07 01:57:47 (17 years ago)
Comment:

new example

Legend:

Unmodified
Added
Removed
Modified
  • TokenExample

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