Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Jun 25, 2023 06:56 PM - edited Jun 27, 2023 01:29 AM
I'm having a hard time cleaning a long text value so that it can be passed to an API as a JSON value via a Post Request. After running lots of different cleaning formulas, which all yield 'bad character' errors, I think I've narrowed the problem down to some strange behavior re: line breaks - as demonstrated in the table below, where the same formula yields oddly different outputs for different text blocks.
REGEX_REPLACE formula is used to replace ''\n" characters w/ Xs
The formula output for record A works as expected. In Record B only some line breaks appear to have been replaced. Record C is a duplicate of Record B that has been modified with one character "$." This modification seems to trigger the formula to find the second set of '\n' characters.
In some cases, while testing this, it seems like the list view and detail view yield different results when I copy and paste them into a text editor. One view yields collapsed text and another yields text with line breaks still in it. I haven't had time to study this problem so it may be hard to replicate.
Any help appreciated.
Jun 25, 2023 07:44 PM - edited Jun 25, 2023 07:45 PM
It is better to match all the line break codes, as they may differ depending on the environment
regex_replace("\r\n|\n|\r","X")
Jun 27, 2023 01:18 AM
Thanks Sho - agreed. This is a good technique. However I still get the same buggy response w/ that formula. It seems not to recognize the characters.