cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
stephenJames
Level: Powered On

Help with ' in strings

Hello,

         I have created a number of flows that use the html to text conversion but have to do some heavy formatting before the conversion to get close to the desired results.

I am wondering if there is a better way.

 

To start i have a long "replace" action that removes some things from HTML email

replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(replace(triggerBody()?['Body'],'<tbody>',''),'</tbody>',''),'<table>',''),'</table>',''),'<tr>',''),'</tr>',''),'<p class="MsoNormal">',''),'</p>',''),'<td valign="top" style="border:none; border-bottom:solid #CCCCCC 1.0pt; padding:5.25pt 6.75pt 5.25pt 6.75pt">',''),'</td>',''),'<br>',''),'<b><span style="color:#333333">',''),'</span></b>',''),'<span style="color:#333333">',''),'</span>',''),'"','')

It then runs through the Html to Text conversion

From here i use substrings to extract the text i would like. However if the text i want is after a line end i get an extra line in my result.

Is there maybe a way to format the email to text to put it all on one line or be able to extract the text with out the extra line.

 

 

 

 

3 REPLIES 3
Super User
Super User

Re: Help Removing all formatting

Hi @stephenJames 

 

Do you mean that you want to access each line of the email and join them as a huge single line? If so, please see the screenshot below: 

Imak.PNG

 

In the first initialise variable, you have to hit and enter key in the value of the variable. The other expressions are: 

split(triggerBody()?['Body'],variables('test'))

to split the email body over every new line

join(variables('xxt'),' ')

joins the split array with a <space>

 

Hope this Helps!

 

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!

stephenJames
Level: Powered On

Re: Help with ' in substring


@yashag2255 wrote:

Hi @stephenJames 

 

Do you mean that you want to access each line of the email and join them as a huge single line? If so, please see the screenshot below: 

Imak.PNG

 

In the first initialise variable, you have to hit and enter key in the value of the variable. The other expressions are: 

split(triggerBody()?['Body'],variables('test'))

to split the email body over every new line

join(variables('xxt'),' ')

joins the split array with a <space>

 

Hope this Helps!

 

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!


Thanks for your suggestion. 

I found another way to remove the whitespace using the trim function. Adding trim in front of all my substrings seemed to remove all the extra white space i was getting. 

Heres an example

trim(substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'Reference #:'),13),sub(lastIndexOf(body('Html_to_text'),'Status:'),add(indexOf(body('Html_to_text'),'Reference #:'),13))))

However i am having a hard time with a ' when trying to define the indexof of a substring

Heres the substring i have

substring(body('Html_to_text'),add(indexOf(body('Html_to_text'),'Requestor's Department'),22),sub(lastIndexOf(body('Html_to_text'),'* Department Approver'),add(indexOf(body('Html_to_text'),'Requestor's Department'),22)))

The ' in Requestor's Department is breaking the code. How exactly do i get it to ignore that while still searching for it?

 

 

stephenJames
Level: Powered On

Re: Help with ' in substring

So by using this 

 

uriComponentToString(replace(replace(uriComponent(body('Html_to_text')), '%0A', ''), '%27',''))

I can remove new lines and remove the apostrophes in the text, which puts everything on one line.

 

However i get the following message when trying to run my flowflowerror.PNG

This is the expression its trying to run

trim(substring(body('Remove_Line_Breaks'),add(indexOf(body('Remove_Line_Breaks'),'Name of Project'),15),sub(lastIndexOf(body('Remove_Line_Breaks'),'* What is your'),add(indexOf(body('Remove_Line_Breaks'),'Name of Project'),15))))

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 212 members 4,120 guests
Please welcome our newest community members: