nkrgupta Posted August 30, 2013 Share Posted August 30, 2013 Hi,I'm trying to display a value after evaluating it with a regular expression. However I'm not sure what is the right way to do that, and hence not getting results. Following is the code I'm using in XML part of the jrxml. <textFieldExpression><![CDATA[( ($F{name}.matches(^.*s-)) ?($F{name}.substring(0,12) + "..."):($F{name}))]]></textFieldExpression>Any help would be much appreciated!Thanks Link to comment Share on other sites More sharing options...
Thomas Zimmer Posted August 31, 2013 Share Posted August 31, 2013 I assume what you wanted to do is:$F{name}.length() >= 12 ? $F{name}.substring(0,12) + "..." : $F{name}Perhaps you have to do an additional check, if "name" is not null first.I see regex as somehow possible but less efficient and overflow here. But the regex expression would be:$F{name}.matches("^.{12,}$") ? $F{name}.substring(0,12) + "..." : $F{name}Of course, the null-check remains here as well.Cheers, Thomashttp://www.ThomasZimmer.net 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