cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ContentGroup
Helper I
Helper I

Removing blank lines

I have some plain text that looks like this:

 

MONDAY, MAY 20
 
 
VICTORIA DAY
 
ALL OFFICES CLOSED
 
 
 
WEDNESDAY, MAY 22
 
 
NORMAL SCHEDULE
 
 
When I try to remove the blank line 
replace(body('Html_to_text'),variables('txtCR'),'')  //txtCR is just a variable with a line break
 
I get this:
 
MONDAY, MAY 20VICTORIA DAYALL OFFICES CLOSEDWEDNESDAY, MAY 22NORMAL SCHEDULE
 
Any suggestions to get an output like this (where there are line breaks after lines with text)?:
MONDAY, MAY 20
VICTORIA DAY
ALL OFFICES CLOSED
WEDNESDAY, MAY 22
NORMAL SCHEDULE
1 ACCEPTED SOLUTION

Accepted Solutions
v-bacao-msft
Community Support
Community Support

Hi @ContentGroup ,

 

Please try the following methods to achieve your needs.

 

  • Initialize String variable-Breakline, and add a carriage return inside Value.
  • Initialize another String variable to store the expected result.
  • Use the variable Breakline to split the Plain text, generate an array, and use Apply to each to iterate over the array.
  • Use Condition to determine whether the currently traversed element is empty. If it is not empty, append the current element to the Text variable. Note that you also need to add a carriage return in Value.

Image reference:

21.PNG22.PNG

Flow run history:

23.PNG

Hope it helps.

 

Best Regards,

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

View solution in original post

4 REPLIES 4
Brad_Groux
Community Champion
Community Champion

You would probably want to convert the text to HTML using the Content Conversion connector (docsso it is easier to figure out which characters are still hanging around in the blank spaces. They discuss it in this thread

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

v-bacao-msft
Community Support
Community Support

Hi @ContentGroup ,

 

Please try the following methods to achieve your needs.

 

  • Initialize String variable-Breakline, and add a carriage return inside Value.
  • Initialize another String variable to store the expected result.
  • Use the variable Breakline to split the Plain text, generate an array, and use Apply to each to iterate over the array.
  • Use Condition to determine whether the currently traversed element is empty. If it is not empty, append the current element to the Text variable. Note that you also need to add a carriage return in Value.

Image reference:

21.PNG22.PNG

Flow run history:

23.PNG

Hope it helps.

 

Best Regards,

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

This does work and I willl accept this as the answer.  The only issue is the respond time is longer than what I would want, the for each loop took about 12 seconds, for my use case this flow is initialized by a http request and ends with a response to that request, so the user's browser is waiting for 12 seconds for the information to come back.

Your solution gave me an idea to speed things up, I create two variables, one with 1 carriage return and one with 2 carriage returns.  then i created an output variable which contained the text, did a do until loop with the criteria of until the output variable does not contain the 2 carriage returns, in the loop i just replace 2 carriage returns with 1 carriage return and this saved about 9 secs:

 

image.pnginside the loop.inside the loop.

 

Thanks for your help

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.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (8,490)