Class RETokenizer


  • public class RETokenizer
    extends java.lang.Object
    The Tokenizer class suggests a methods to break a text into tokens using occurences of a pattern as delimiters. There are two ways to obtain a text tokenizer for some pattern:
     Pattern p=new Pattern("\\s+"); //any number of space characters
     String text="blah blah blah";
     //by factory method
     RETokenizer tok1=p.tokenizer(text);
     //or by constructor
     RETokenizer tok2=new RETokenizer(p,text);
     
    Now the one way is to use the tokenizer as a token enumeration/iterator:
     while(tok1.hasMore()) System.out.println(tok1.nextToken());
     
    and another way is to split it into a String array:
     
     String[] arr=tok2.split();
     for(int i=0;i
    See Also:
    Pattern.tokenizer(java.lang.String)