This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes Regular expression Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regular expression" Watch "Regular expression" New topic
Author

Regular expression

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Split method

I want to know how the following 2 cases worked in the example mentioned in the above link


[ December 14, 2004: Message edited by: Pradeep Bhat ]

Groovy
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34



If the limit is negative, the actual value doesn't matter. The negative value just means to split into as many tokens as possible, and preserve any trailing empty tokens.



In this one, the first empty string is between the first two "o"s, the second empty string is between the other two "o"s, and that last empty string is there because the target ends with a delimiter, and the empty string is "after" that.


[Jess in Action][AskingGoodQuestions]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Thanks Ernest for the great explanation.
 
 
subject: Regular expression