cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
This-n-That
Frequent Visitor

Extracting data from between 2 delimiters

I have a flow that needs to pull data from the body of an email. The email comes in and updates a multi-line text column with the entire contents of the body. This throws in a bunch of junk at the start and end of the email. I need all the data between the word "Show:" and the phrase "Technology Group". I've tried the following expressions to extract between the two, but neither works.

 

Extracting directly from the email body: last(split(first(split(triggerBody()?['bodyPreview'],'Show:')),'Technology Group'))

 

Extracting from the data stored in the column: last(split(first(split(outputs('Update_item_2'?['body/Body'],'Show:')),'Technology Group'))

 

The second expression is invalid and I don't know how to make it work. It seems like extracting between these two delimiters would work if I could get the expression right.

 

The first solution I tried was using a Text Function to find the text positions for "Show:" and "Technology Group" and then start the extraction, but that doesn't work perfectly, either. I can start the extraction in the right spot, but because the amount of data varies, I end up extracting all the junk at the end of the email beyond my second delimiter "Technology Group". That got me wondering:

 

Can I use the text position for my first delimiter "Show:"? and subtract it from the text position for the second delimiter "Technology Group"? The Text Position action counts the exact location of each delimiter, which can vary depending on the amount of data. So my flow process would be something like this:

 

Count text position for "Show:"

Count text position for "Technology Group"

Math calculation "text position Technology Group - text position Show:"

Use the product of the math calculation to determine the end point of my substring:

 

ThisnThat_0-1638815836639.png

Any suggestions?

1 ACCEPTED SOLUTION

Accepted Solutions
This-n-That
Frequent Visitor

I figured it out. I set some variables with the position of "Show:" and the position of "Technology Group" and used the variables in my Compose action to calculate the stopping point. Then I set a variable with the calculated value of the stopping point and used that in my substring and pulled all the data between the two points:

 

sub(variables('varTechGrp'),variables('varShow'))

 

ThisnThat_2-1638894352185.png

 

I knew it was possible, but I was too busy trying to use the outputs from the Text Function in the calculation rather than variables.

 

ThisnThat_0-1638894018753.png

 

View solution in original post

3 REPLIES 3
ScottShearer
Super User
Super User

@This-n-That 

Can you post a sample of the that string you are trying to parse?

 

 

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

Scott
This-n-That
Frequent Visitor

It's pretty massive. When I paste the output into Word, it's 50 pages long. When I start the extraction at "Show:", it begins where I want it. What I need to do is calculate exactly where to end so I don't get all the junk. Here is what my flow looks like:

 

ThisnThat_0-1638819128139.png

 

This-n-That
Frequent Visitor

I figured it out. I set some variables with the position of "Show:" and the position of "Technology Group" and used the variables in my Compose action to calculate the stopping point. Then I set a variable with the calculated value of the stopping point and used that in my substring and pulled all the data between the two points:

 

sub(variables('varTechGrp'),variables('varShow'))

 

ThisnThat_2-1638894352185.png

 

I knew it was possible, but I was too busy trying to use the outputs from the Text Function in the calculation rather than variables.

 

ThisnThat_0-1638894018753.png

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Top Solution Authors
Top Kudoed Authors
Users online (3,466)