cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
JimmyWork
Super User
Super User

Split at \r\n\r\n

Hi

 

Im trying to split an email body preview at \r\n\r\n but the split does not seem to work.

split(body('Parse_JSON')?['bodyPreview'], '\r\n\r\n')

I just end up with one line, nothing is split 

1 ACCEPTED SOLUTION

Accepted Solutions
efialttes
Super User
Super User

Hi!

Guess this same problem happens when dealing with CSV files.

If so, some threads in this same community discussing this other topic, like

https://powerusers.microsoft.com/t5/Building-Flows/Split-method-parse-csv/td-p/514345

 

Use uriComponent() function to convert the string into URI code, then use replace() function to replace line separator("%0D%0A") and add ";" instead, then use decodeUriComponent() to decode it

...

Then use the split() function to create an array:
split(outputs('Compose'),';')

Hope this helps

 

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

7 REPLIES 7
efialttes
Super User
Super User

Hi!

Guess this same problem happens when dealing with CSV files.

If so, some threads in this same community discussing this other topic, like

https://powerusers.microsoft.com/t5/Building-Flows/Split-method-parse-csv/td-p/514345

 

Use uriComponent() function to convert the string into URI code, then use replace() function to replace line separator("%0D%0A") and add ";" instead, then use decodeUriComponent() to decode it

...

Then use the split() function to create an array:
split(outputs('Compose'),';')

Hope this helps

 

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



_Ken
Advocate II
Advocate II

\r can be addressed as decodeUriComponent('%0D')
\n as decodeUriComponent('%0A')
One simple solution with multiple \r\n\r\n as follows:

 

split(body('Parse_JSON')?['bodyPreview'], decodeUriComponent('%0D%0A%0D%0A'))

 

 

john_dawson
Frequent Visitor

Thanks for that; worked for me - and only thing that did, after trying other suggestions

Hi Ken,

 I sent my email body to a variable and wrote the following expression in a compose action.

split(variables('EmailBody'), decodeUriComponent('%0D%0A'))
This works. I see the right data in the right format/line spacing coming out of the compose.
However, when I then take the output of the compose and put it into a Azure DevOps action to create a work item, when the work item gets to ADO, all the line spacing is gone and it's one big paragraph again. Any ideas on this?

Quick test of the ADO 'Create a Work Item' action seems to indicate it differs from field to field.

Description - seem to prefer a html <br>

Repro Steps - seem to truncate any line breaks

Best way to find out is looking at the Power Automate run results input/output and experiment with different  line break types.

FreeRangeDingo
Helper II
Helper II

This is what worked.

 

FreeRangeDingo_0-1674688736204.png

 

Awesome - nice solution. 

Will add that to my list of script snippets.

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,772)