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:
Any suggestions?
Solved! Go to Solution.
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:
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.
Can you post a sample of the that string you are trying to parse?
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:
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:
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.
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
27 | |
27 | |
26 | |
13 | |
12 |
User | Count |
---|---|
58 | |
51 | |
30 | |
27 | |
27 |