like "-40.23-50.45,-30,40,<30,>50"

where i should consider "," is different set of values

and

"-40.23-50.45" means i have to split it as -40.23 to 50.45

"-30" as -30

"40" as 40

"<30" means values less then 30

">50" means values greater then 50

Thanks in advance

-Chiru

Best of luck.

"-40.23-50.45" means i have to split it as -40.23 to 50.45

Is it 40.23 to 50.45 ? Both have - in front of them. BTW, show us what you have done already and what problem you are having now ?

SCJP 5 | SCWCD 5

[How to ask questions] [Twitter]

String[] si=s.split("-",2);

It looks like you think that this looks from position 2 in the string onward. But this is not what it does. Look it up in the API documentation:

public String[] split(String regex, int limit)

Splits this string around matches of the given regular expression.

The array returned by this method contains each substring of this string that is terminated by another substring that matches the given expression or is terminated by the end of the string. The substrings in the array are in the order in which they occur in this string. If the expression does not match any part of the input then the resulting array has just one element, namely this string.

The limit parameter controls the number of times the pattern is applied and therefore affects the length of the resulting array. If the limit n is greater than zero then the pattern will be applied at most n - 1 times, the array's length will be no greater than n, and the array's last entry will contain all input beyond the last matched delimiter. If n is non-positive then the pattern will be applied as many times as possible and the array can have any length. If n is zero then the pattern will be applied as many times as possible, the array can have any length, and trailing empty strings will be discarded.

You'd see that if the input is "-40-50", the call to split in line 14 results in two strings: "" and "40-50" - because it has done the split one time, around the first "-".

I agree. Here's the better link: Salvin.in