Formatting text field possibly using regex


A single field (description)  in the database is being returned as a large string

 So subsequent fields would look like
How do I render each field $F{description} so it is readable so to access city field to return nottingham, leeds london etc. Or to access car $F{description} field. Have found some examples on the formatting using regex but nothing is particularly clear. Is there any formatting option in JasperStudio I am missing


JR_Data's picture
Joined: Jul 15 2017 - 7:02am
Last seen: 2 months 1 week ago

1 Answer:


You may or may not be able to pull this off by nesting a bunch of the "TEXT" functions built in to jaspersoft studio, combining 'substitute',and 'search' to whittle this string down to everything between the third and fourth instances of '-', but I don't recommend it. If it is possible, it's not easily maintainable. What you could do is add apache's commons-lang jar into your project, split that string (using, no surprise, the StringUtils.split() method) on the '-' hyphen char, and return the appropriate string from the resulting array list. The split method can split your string into an array list of strings based on a given character.

Also, to be fair, Java also has a string split method, but it's not as intuitive:,%20int)

And finally, I'm sure you can do this via regex as well, but again it's not as intuitive as the apache commons-lang approach:


darth_fader's picture
Joined: Mar 7 2010 - 9:45pm
Last seen: 1 day 1 hour ago