| Author |
Doubt in split().
|
Amit Batra
Ranch Hand
Joined: Mar 04, 2006
Posts: 361
|
|
The above is a question from whizlab simulator. Can anyone please tell me how the output is coming to be 4? I thought the split method is supposed to split a string around matches of a regex. here regex is a{3} so doesnt that leave bb to be the two tokens.??
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
The tokens are "", "", "", "bb" as shown below: [ August 13, 2006: Message edited by: Barry Gaunt ]
|
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
|
 |
Amit Batra
Ranch Hand
Joined: Mar 04, 2006
Posts: 361
|
|
BUt how can a string of zero length be considered a token when I havent used any kind of greedy quantifier? And going by the explanation. there is a token on the left of the first ""aaa. Then why isnt there also a token just before the BB. like aaa""bb".? I hate regexing
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
|
The "bb" is the token. Just before this token there is the separator "aaa".
|
 |
 |
|
|
subject: Doubt in split().
|
|
|