Unable to replace line brakers \n with <br>

Hi,
We receive an HTML‑formatted string from a downstream system, for example:

"text": "<fieldset style=\"border:0px;\"><h2 style=\"margin-top:16px;\">Bhargav</h2><ul><li>Date: 17-Mar-2026</li><li>Interaction is an initial assessment</li><li>Therapy session number: 0</li><li>Patient is suitable to start therapy</li></ul><h2 style=\"margin-top:16px;\">Assessment Screener</h2><ul><li>Further information from Assessment Screener: Sir David Attenborough's 100th birthday will be celebrated with three special programmes, the BBC has announced.\n\nThe corporation will mark Sir David's \"extraordinary milestone\" on 8 May with a week of special programming featuring new and old shows by the beloved presenter.\n\n</ul></li>"

We display this in a Rich Text Editor, which correctly renders the HTML, but the \n line breaks are not shown in the UI.

My requirement is to ensure that every \n starts a new line.
However, the clipboard does not show any \n characters, and using a replaceAll function does not work because the property value no longer contains \n.

Example attempted:

@String.replaceAll(.Property, "\\n", "<br>")

Do you have any suggestions on how to handle this in Pega itself, without requiring changes from the downstream system?

can you please try this

@String.replaceAll(
@String.replaceAll(.Property, “\r\n”, “”),“\n”,“”)

As another option, you might want to try the Markdown editor control. It’s part of the Constellation UI Gallery. I think it deals with coded text better than the rich text viewer. The benefit here is you don’t have to manipulate the text at all.

1 Like