Regular expression to compare numbers

I have a method

compare(Object value, String searchTxt);

The value can either be a Number, Date, String.

The searchTxt can have values to compare Strings, Dates, Numbers. It also can have logical comparison operators like =, !=, >, <, >=, <= eg.

compare(numValue, "> 1000 <= 2000)

compare(dateValue, "> 2006/12/12 <= 2007/01/25)

compare(stringValue, "> abc <= xyz )

Can I have some regular expression to control this comparision and make my life little easier. Because spliting the string and checking for all possible options can be a tedious job.

Peace n Regards

[649 byte] By [chandrajeeta] at [2007-11-26 16:20:09]
# 1
So are you wanting to know whether 'searchTxT' is a Number or a Date (if neither Number or Date then just any old String). If so then you will need to define the syntax of both Number and Date better than you have so far.
sabre150a at 2007-7-8 22:43:41 > top of Java-index,Java Essentials,Java Programming...
# 2

No. The searchTxt can have values like

"> 1000 <= 2000"

"> 2006/12/12 <= 2007/01/25"

"> abc <= xyz"

But I can check for the instanceof for the "value" and know that the searchTxt contains logical opearators plus (only Number or only Date or only String).

The real requirement is to comare the "value" according to the search string.

Say for eg:

if the method compare is invoked as compare(200, ">=100<500") it should return true

if the method compare is invoked as compare("xyz", ">=abc<xxx") it should return false

and so on...>

chandrajeeta at 2007-7-8 22:43:41 > top of Java-index,Java Essentials,Java Programming...
# 3
Not easy with regex! You need a parser.
sabre150a at 2007-7-8 22:43:41 > top of Java-index,Java Essentials,Java Programming...
# 4
do you mind if we ask what this is for? i hope this is some kind of programming exercise because if this is by design it's horribly flawed.
den2681a at 2007-7-8 22:43:41 > top of Java-index,Java Essentials,Java Programming...
# 5
Ok. I have a swing based application. I have to search thru a JTable grid based on different search criterias. I take the search criteria thru a textField.
chandrajeeta at 2007-7-8 22:43:41 > top of Java-index,Java Essentials,Java Programming...