| Author |
Token Question
|
Alan Hermin
Ranch Hand
Joined: Feb 16, 2006
Posts: 290
|
|
Hi Ranchers....... i will take a test at these days... i have a question about Tokens: I Think if i use the token using <String.split> method , THEN use the same source and regex at the Scanner class, THE OUTPUT MUST SAME,,Take The code: code: -------------------------------------------------------------------------------- String input="10 Apples 20 Oranges 33 Pears"; Scanner sc=new Scanner(input).useDelimiter("\\d*"); while(sc.hasNext()) System.out.println(">"+sc.next()+"<"); -------------------------------------------------------------------------------- -------------------------------------------------------------------- And the code: code: -------------------------------------------------------------------------------- String input="10 Apples 20 Oranges 33 Pears"; String[]arr=input.split("\\d*"); for(String xx:arr){ System.out.println(">"+xx+"<"); } -------------------------------------------------------------------------------- THE OUTPUT in the String.split version return more data than the first one. PLEASE HELP..
|
 |
 |
|
|
subject: Token Question
|
|
|