This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma 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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Regular expression" Watch "Regular expression" New topic

Regular expression

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

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 ]

Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

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: 8927

Thanks Ernest for the great explanation.
I agree. Here's the link:
subject: Regular expression
It's not a secret anymore!