Search and replace Carriage Returns CR in Data Bindings

How can I do a search and replace for this Carriage Return character?
'↵'

Here is a typical result in a Data Binding

N/S/F Wing + Liner + Trim ↵N/S/F Door + Foil + Trim ↵N/S/R Door + Foils ↵N/S/R Road Wheel + Tyre ↵Trims Clips and Sundries

I have tried this but doesn’t work

image

In PHP I can do this ('str_replace') which does work

<?php echo str_replace(array("\r\n\r\n", "\r\n", "\r", "\n", ","),"<br>",$_SESSION['for_PDF']['meth_replace']); ?>

Hey @UKRiggers , did you work out the answer to this? I have the same problem!

I know this is one option I used

dmx-bind:value="sc_ad_job_q.data.sa_q_job_q.meth_specialist.replace(',', '\r')"

@UKRiggers, that is good for creating a new line…

I want to replace a new line created from a textarea with a <br>… did you find a way to do this?

Or @teodor, can you help us here?

I’ve tried:

.replace('\n', '<br>')
.replace('\\n', '<br>')
.replace('\r', '<br>')
.replace('\r\n', '<br>')

I’m using PHP…

Will it not work the other way round?

.replace('\r', '<br>')

Scrap that then :smile:

try

.replace(/\r?\n/g, '<br>')

@patrick, that doesn’t work either!

.replace(/\r?\n/g,'<br>')

Seems that php doesn’t support regexp like app connect. The .replace('\n', '<br>') should work.

Please check directly in the generated php file what the expression is, I noticed when I tested that in my test case the \n did get escaped to \\n in the code.

Hi there @patrick

Yes, I’ve been able to fix it by replacing \\n to \n in the PHP source code.

That is not an easy fix to sustain, as it resets to \\n whenever I do a save of the server action file!

Best wishes,
Antony.

I’ve submitted a bug report!