Replace line breaks in fields with string \n
Options
Rapp_116094
Posts: 7
Hi support team,
for an API call I need values from a field separated with "\n" as string. The values are already separated by a \n in the source field.
Currently I have no further idea how to replace the line breaks with actual "\n" strings.
I have already tested:
- Action Find and Replace
- JS: Replace with Regex
- JS: Replace with # and then again with string "\n".
- Overwrite a short text field that does not allow line breaks
Is there another possibility?
The final result should look like this:value1\nvalue2\nvalue3
instead of:
value1
value2
value3
Thank you in advance!
0
Comments
-
Hi @Rapp_116094 This RegEx Field Formula should work for you:
result = fields["text-with-line-breaks"].replace(/\n/gm,'\\n');
The extra
\
before the\n
for the replacement text ensures that you use the literal\n
text, rather than re-inserting a line break.1 -
Hi @Jeff_763648 thank you for sharing the RegEx. The conversion worked.
1