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 Platform Community / Forums / Power Automate / Remove carriage return...
Power Automate
Answered

Remove carriage return (line break) \r\n from string

(0) ShareShare
ReportReport
Posted on by 42

Hi all,

 

I'm in trouble with removing carriage return from a string in Power Automate.

From Teams I'm using Power Virtual Agent and a user can send a message in two lines (or more).

This message is sent to Power Automate to compose a Json, but I cannot be able to remove the line break.

This is an input example:

 

ariccia79_0-1657283800106.png

 

Using the expression split(variables('DescriptionParsed'), '\r\n') I can see the output with \r\l

ariccia79_1-1657283922722.png

 

But next, when I "Apply to each item" to replace "\r\n" with empty string to have the text in a row, it doesn't work:

 

ariccia79_2-1657284034033.png

 

I've also tried without array, using join(split(variables('DescriptionParsed'), '\r\n'), '') but nothing has changed.

 

I need that

Ciao, ho un problema

con la stampante

will result as

Ciao, ho un problema con la stampante

 

I've tried a lot of solutions, but nothing is working for me.

 

How can I remove the new lines??

Thank you

 

 

Anna

 

 

Categories:
I have the same question (0)
  • Verified answer
    ariccia79 Profile Picture
    42 on at

    I've resolved it! 😭

    I can do it in a single line, using

    split(MYSTRING, decodeUriComponent('%0D%0A'))

    I can split in the right way my string with \r\n

     

    I need to replace them with whitespace to have text in a single row, so I'm using a join

     

    My final expression is:

    join(split(MYSTRING, decodeUriComponent('%0D%0A')), ' ')

  • Steve48 Profile Picture
    431 on at

    How do you enter it into the join dialog box 

  • ariccia79 Profile Picture
    42 on at

    In MS Teams, you can enter a new line with key ENTER and SHIFT or ENTER and ALT.

  • Steve48 Profile Picture
    431 on at

    Thank you for responding. My interest was really for power automate desktop. I found out that they have an action that will split text on a new one and also an action to join list elements with a space so that solved my problem

  • bu11frogg Profile Picture
    130 on at

    I had a multiline text column from SharePoint with blank rows (extra line spacing) between each line of text.  I tried replace() on the text from SharePoint, and I also tried trim().  Then I found this article, but I could not get the join / split solution (above) to work, either.  However, the "decodeURI" part of that expression got me thinking.

     

    I ended up using an expression to encode the original text, then another expression to replace the %0A (my text only had \n for a new line char), then another expression to decode the text again.  It works well.  Here are the screenshots and expressions if it will help anyone.

     

    bu11frogg_0-1696517421043.png

     

    The expression from the 1st Compose action is just encoding the text from the original SharePoint item's multiline text field:

    encodeUriComponent(outputs('Get_item')?['body/ApprovalText'])

     

    Compose 2's expression replaces 2 newlines ('%0A%0A') with a single newline ('%0A'); you could just replace with '' to get rid of the new line completely:

    replace(outputs('Compose'),'%0A%0A','%0A')

     

    Compose 3 just decodes the result of Compose 2 back to "normal" text:

    decodeUriComponent(outputs('Compose_2'))

     

    Hopefully that helps someone.  

  • aniuafen Profile Picture
    19 on at

    Very useful thanks ! Tried replacing \n\n with \n and it didn't work even if you could clearly see this in input. Luckily your solution worked

  • jcneto25 Profile Picture
    6 on at

    Life saving tip !!!! Thanks

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 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard