How to use .Replace() function on text

My database of messages contains text, including on 2 or more lines, coming from a form earlier.
In mySQL they look like this, 2 lines for example.
image

A query returns the text with \r\n as expected in the console
image
So I try to replace \r\n with a <BR>

{{body}}<BR>   <--- This returns the correct body, but on 1 line
{{body.replace('\\r\\n', '<BR>')}}  <--- this tries to replace \r\n by <BR>

But here is the display. First line shows text, but no return. 2nd line the replace() function isn’t applied.
image

Is there something I’m missing to make this apply as expected?
Thank you for the help :slight_smile:

I’m on my mobile so can’t test but you could do something like: .replace('&#92;r&#92;n', '<br>')

You also need to do it as dmx-html attribute of an element for it to render the html

Please try: .replace('\n', '<br>')

Thank you @bpj and @Teodor
It works when it is in a dmx-html, and it works with \n or \r\n
<p dmx-html="body.replace('\r\n', '<BR>')"></p>

1 Like