web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Extracting data from b...
Power Automate
Answered

Extracting data from between 2 delimiters

(0) ShareShare
ReportReport
Posted on by 45

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?

Categories:
I have the same question (0)
  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @This-n-That 

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

     

     

  • This-n-That Profile Picture
    45 on at

    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

     

  • Verified answer
    This-n-That Profile Picture
    45 on at

    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

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard