cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Paul1
New Member

replacing newline

I'm trying to replace newline \n with an * using the following compose   @replace(body('Html_to_text'),'\n','*').    Nothing happens, I have tried several variation of this function   /\n   /\n/  "/n" ..  

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Paul1
New Member

Re: replacing newline

Mike, thanks but the "Char()" function is not supported.  Although I figured it out, you have to LITERALLY put the new-line in the FLOW in single quotes.     This works: 

 

@replace(body('Html_to_text'),'

','*')

View solution in original post

10 REPLIES 10
Community Support
Community Support

Re: replacing newline

Hi @Paul1,

 

Could you please share your flow configuration in a screenshot?

The replace function would work for string, and if you would like to replace the CRLF code into "*", I think that may not be available through the replace function.

You may take a try with the code below:

@replace(body('Html_to_text'),char(13),'*')

Char(13) here means the newline (CR).

See if it would work in this way.

Regards,

Michael

 

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Paul1
New Member

Re: replacing newline

Mike, thanks but the "Char()" function is not supported.  Although I figured it out, you have to LITERALLY put the new-line in the FLOW in single quotes.     This works: 

 

@replace(body('Html_to_text'),'

','*')

View solution in original post

Anonymous
Not applicable

Re: replacing newline

Thanks Paul, it was driving me mad trying to find a way of doing this and your post pointed me in the right direction.  

I couldn't get it to work exactly as you did but instead I intitialised a variable - which I called "crlf" - at the top of the Flow. I set that to a literal carriage return as you did (by pressing the Enter key) and then used the variable in the "replace" function as follows: (I had a "Data Operations - Compose action called "Message" which contained some Sharepoint list multiline plain text columns which I wanted to format properly within a HTML email, so needed to replace line endings with the <br /> tag).

 

This is as entered in the expression editor (so no @ symbol):  replace(outputs('Message'),variables('crlf'),'<br />')
Anonymous
Not applicable

Re: replacing newline

Hi @Anonymous,

 

I'm facing the same issue, try to replace the new lines with a " * ".

Can you provide a screenShot please of the flow, soory i didn't get the solution that you mentioned.

 

Thank you.

Highlighted
Anonymous
Not applicable

Re: replacing newline

Hi Marwa1,

The screenshot below is an example of replacing newlines with asterisks as you were trying to do.

In the "Initialize variable" step Value looks empty but in fact it contains a newline character (entered by pressing the Enter key).

In the "Compose 2" step the expression in full is 

replace(outputs('Compose'),variables('crlf'),'*')
 

FlowExample.JPG

 

 

Running the flow gives the following output:

 

FLowScreenShot1.JPGFLowScreenShot2.JPGFLowScreenShot3.JPG

Anonymous
Not applicable

Re: replacing newline

Hi @Anonymous,  Sorry the second set of screenshots above is jumbled - hope they make sense.

Paul1
New Member

Re: replacing newline

CollinB, your solution is much more elegant, then mine..! 

Anonymous
Not applicable

Re: replacing newline

@Paul1 - I'm not sure about that ! 🙂

Anonymous
Not applicable

Re: replacing newline

worked perfectly!!!

 

malbornoz
Regular Visitor

Re: replacing newline

This worked perfectly for me, thanks!

 

For those who are looking what that 'Compose' action is in the spanish version look no more, it's 'Redactar' under 'Operación de datos'. 

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Users online (6,139)