Search code examples
postgresqljasper-reports

How to replace carriage return \n with a space


So in jasper I have a field that has a variable in it to format the string but in the webapp where I am getting the data from it will print the carriage return such as "line1\nline2\nline3\nline4" How would I fix this?

SELECT
  CAST(modulesettings.value::json->'soReportFooter' AS varchar) AS footer_value
FROM modulesetting
WHERE modulesetting.key = 'sales'

Then the variable expression to take the quotes of the end is
$F{footer_value}.substring(1, $F{footer_value}.length() -1)


Solution

  • Use a string function:

    SELECT
      replace(CAST(modulesettings.value::json->'soReportFooter' AS varchar, '\n', ' ') AS footer_value
    FROM modulesetting
    WHERE modulesetting.key = 'sales'