I have a flow that is parsing a plain text email and creating an item in a SharePoint list.
Everything works great except for when a user enters data with a newline or carriage return (which I don't want in the SP list). I can not figure out how to replace a new line (\n) or any other non-printable character.
I have tried the obvious...
replace(body('Html_to_text'), '\n', '')
I have tried what others claim to be the only solution...
replace(body('Html_to_text'), ' ', '')
As well as several other options (e.g.; character codes)...
replace(body('Html_to_text'), Char(13), '')
And nothing works (even when the run doesn't generate an error, the new lines are not replaced). I am able to replace printable characters without issue, it's just the non-printable characters.
So, am I missing something or is it impossible to do what I'm trying to do?
In my case I needed to replace \r\n so it was
Hi,
I am trying to export a SharePoint list into a CSV file. One of the columns has got \n (linefeed) and it is causing the breaking of the rows.
I tried to use the following expression in compose before creating csv file
uriComponentToString(replace(uriComponent(body('select')), '%0A', ''))
I am getting following error, can someone direct me to right place or help .. thank you.
I've been working on this for weeks! Converting an HTML table into a Sharepoint list item then to email. This was the piece I couldn't fix. It works great!
That is great, I have been trying to fix the seemingly random addition of non printable characters for ages. Agree it isn't pretty but definitely did the job. Thanks FlowNick!
use concat and {" \n\n"} ... yes with double quotes
example >>> concat('string 1',{" \n\n"},'String 2')
This will output
string1
string2
I tried reversing the solution - using decodeUriComponent to get the newline for the split. Works as well.
replace(body('Html_to_text'), decodeUriComponent('%0A'), '')
Thanks @Megasween thanks works perfect. A recap for others:
@FlowNick wrote:Thanks Michael.
Here's what I'm currently using as a workaround:
uriComponentToString(replace(uriComponent(body('Html_to_text')), '%0A', ''))I figured, since I can replace printable characters, I'd just temporarily convert the string to all printable characters, replace them, then convert it back. It's hack-ish and inefficient but working.
I look forward to seeing your results.
I hate to Necro, so sorry in advance.
I am using a similar bit of code to remove line breaks and apostrophes.
uriComponentToString(replace(replace(uriComponent(body('Html_to_text')), '%0A', ''), '%27',''))
This works to put evrything on a single line and removes the characters i dont need. However i cannot seem to get my substrings to run as i keep getting the following message
@FlowNick mentioned that he " temporarily convert the string to all printable characters, replace them, then convert it back." . Is there a step to convert it back that i am missing?
It works!! You saved me a lot of time and I'm really thankful
WarrenBelz
146,743
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,079
Most Valuable Professional