scottmacpherson Posted February 26, 2008 Share Posted February 26, 2008 Hi all.I'm struggling this one. I want to find out if a field equals any of a list of values. Hard to explain, but I basically want to do an SQL IN type query, but in a report expression.I've tried using:Code:$F{Field}.matches("(bananas|apples|oranges)"«»)with no sucess. In the above example, I want TRUE to be returned if the Field contained either 'bananas', 'apples' or 'oranges', but not anything else.I also fiddled with the syntax of the above, but even something like:Code:[code]$F{Field}.matches("^(bananas|apples|oranges)$"«»)doesn't work.Any ideas on how to achieve this, or pointers as to where I'm going wrong with .matches?Thanks. Link to comment Share on other sites More sharing options...
vinays84 Posted February 27, 2008 Share Posted February 27, 2008 if $F{Field} is of type String, you should look at the java.lang.String API. http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html It as ample methods available to handle exactly what you are suggesting. Link to comment Share on other sites More sharing options...
scottmacpherson Posted February 27, 2008 Author Share Posted February 27, 2008 Cracked it: for some reason doing a .trim on the field solves everything. I have no idea why blank characters are being added to the field, and whether this is my database or iReports doing this, but problem solved. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now