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

Skip first and last n-characters

Hi,

 

i have an email body converted to text from html but the body contains 2 embeded images so the start and the end of the body is [cid:ismage001.jpg@01Da58sd5D1.A6FaaD87F0] or something like.

 

so the body is :

[cid:ismage001.jpg@01Da58sd5D1.A6FaaD87F0]

 

Email text bla bla

Email [text bla bla22]

Email text bla bla

Email [text bla bla33]

 

[cid:ismage001.jpg@01Da58sd5D1.A]

 

i want to keep only the text and remove from the beginning and from the end [cid:ismage001.jpg@01Da58sd5D1.A6FaaD87F0] and [cid:ismage001.jpg@01Da58sd5D1.A] because i want to build another email to send with my images.

 

So, what is the function to skip first n-chars and remove the the last?

I did alot of mess because there are many [ ] and not the only ones at the begenning and at the end

Maybe i have to array the brackets and remove the first and last? How to do that?

Sorry for bad English

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User
Dual Super User

Re: Skip first and last n-characters

Let's say that a variable call varText contains the following:

 

"[cid:ismage001.jpg@01Da58sd5D1.A6FaaD87F0] Email text bla bla Email [text bla bla22] Email text bla bla Email [text bla bla33] [cid:ismage001.jpg@01Da58sd5D1.A]"

 

then the following formulas will strip out the beginning and ending image designation.

substring(variables('varText'),Add(indexOf(variables('varText'),']'),1))
substring(outputs('Compose'),0,lastIndexOf(outputs('Compose'),'['))

put the first in a Compose action.  That strips off the front.  Then put the second in another Compose action.  That takes the result from the first Compose and strips off the last.

 

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

3 REPLIES 3
Dual Super User
Dual Super User

Re: Skip first and last n-characters

If you know how many characters you need to strip off each end then you can use Substring(text, startindex, length).

 

If you don't know, but know what needs to be stripped out then you can use a combination of Substring(), IndexOf, and LastindexOf to find the locations of the start or end of what needs to be stripped out and calcu.ate from there. 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Spydax
Level: Powered On

Re: Skip first and last n-characters

Yeah, can you explain me better in my case how to apply this functions giving me an exemple?

Thnak you

Dual Super User
Dual Super User

Re: Skip first and last n-characters

Let's say that a variable call varText contains the following:

 

"[cid:ismage001.jpg@01Da58sd5D1.A6FaaD87F0] Email text bla bla Email [text bla bla22] Email text bla bla Email [text bla bla33] [cid:ismage001.jpg@01Da58sd5D1.A]"

 

then the following formulas will strip out the beginning and ending image designation.

substring(variables('varText'),Add(indexOf(variables('varText'),']'),1))
substring(outputs('Compose'),0,lastIndexOf(outputs('Compose'),'['))

put the first in a Compose action.  That strips off the front.  Then put the second in another Compose action.  That takes the result from the first Compose and strips off the last.

 

 



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

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 Power Automate Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 85 members 5,385 guests
Please welcome our newest community members: