How to remove line breaks/newline characters from Text Area before sending through Connect REST?

Hi Team,

I am facing an issue while sending a Text Area property to an external system through Connect REST.

The user can enter multiple lines in the Text Area, for example:

Plain Text
Address Line 1
Address Line 2
Hyderabad

When this value is sent to the external system, the request fails. However, if the same data is entered and sent as a single line, the external system accepts the request successfully.

I need to convert the Text Area value into a single line before sending it through Connect REST, for example:

Plain Text
Address Line 1 Address Line 2 Hyderabad

I initially assumed that each new line would be represented as \n, so I tried:

Plain Text
@String.replaceAll(.Address, “\n”, " ")

However, this is not removing the line breaks.

Could someone please suggest the recommended way in Pega to identify and replace actual newline/line-break characters with a empty or space before sending the value to the external system?

For example, would something like handling both \r\n and \n separately be the correct approach?

Thanks in advance.

I tried with this and it is working fine

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