Search code examples
jasper-reports

How can I remove "-" and Display blank from pincode?


I have one XML document which has a pin code filed and value is "--60000". I am using pin code as a string. now, I want to replace "-" with a blank digit from pin code in Jasper Report.

I was tried with this expression.

(($F{pincode}==null?"":($F{pincode}.substring(0,$F{pincode}.length()-6))!="-"?"":$F{pincode}.substring(0,$F{pincode}.length()-6))) Is there any solution?


Solution

  • You can use:

    ($F{pincode}==null?"":$F{pincode}).replaceAll("-", " ")
    

    EDIT:

    Maybe that would make what you need:

    (($F{pincode}==null?"":$F{pincode}).startsWith("-") ? "" : $F{pincode}.charAt(0)