This week's book giveaway is in the JDBC forum. We're giving away four copies of Make it so: Java DB Connections & Transactions and have Marcho Behler on-line! See this thread for details.

Hi i need a regular expression to parse the String which is entered from text box

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

This doesn't have anything to do with Swing (yes, you get the String from a GUI text field, but that really doesn't matter in the String's parsing), and I'm going to ask the moderators to move this to one of the main Java forums. My question for you is: what have you tried so far and in what way does your current code not work?

The split method in line 14 of your code probably does not do what you think it does:

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 "-".