web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Automate
Answered

Split at \r\n\r\n

(1) ShareShare
ReportReport
Posted on by 2,563

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 

Categories:
I have the same question (0)
  • Verified answer
    efialttes Profile Picture
    14,756 on at

    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

     

     

  • _Ken Profile Picture
    120 on at

    \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 Profile Picture
    8 on at

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

  • FreeRangeDingo Profile Picture
    114 on at

    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?
  • _Ken Profile Picture
    120 on at

    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 Profile Picture
    114 on at

    This is what worked.

     

    FreeRangeDingo_0-1674688736204.png

     

  • _Ken Profile Picture
    120 on at

    Awesome - nice solution. 

    Will add that to my list of script snippets.

  • BellaM Profile Picture
    14 on at

    Thank you so much efialttes!

  • BellaM Profile Picture
    14 on at

    Thank you so much efialttes!

  • IanIrvine Profile Picture
    29 on at

    I Spent an hour arguing with Microsoft Copilot about this then noticed in the code view in Power Automate that when I was splitting by '\r\n' the code was '\\r\\n'

     

    However your approach worked first time

     

    trim(split(split(triggerOutputs()?['body/body'], 'Depot: ')[1], decodeUriComponent('%0D%0A'))[0])

     

    reading the body of my email and splitting the string up based on the text after 'Depot: ' and before the \r\n

     

    Thanks again, this one has been bugging me for a few hours

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard