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 / parsing text from emai...
Power Automate
Unanswered

parsing text from email's body with same tag's title and different values

(0) ShareShare
ReportReport
Posted on by 294
Hi, I would like to parse the text from a following type of text_



Part number: AAA000



Description: Test1



Qty: 10



Part number: BBB000



Description: Test2



Qty: 5



Part number: CCC000



Description: Test3



Qty: 12





I would like a function that would pass the text of each part number and not just the last one.



The output I would like to have is:



Part number 1: AAA000

Part number 2: BBB000

Part number 3: CCC000



It's possible?
Categories:
I have the same question (0)
  • v-bofeng-msft Profile Picture
    on at

    Hi @gennarodp :

    I noticed that each line is separated by 3 lines. I don't know if this is a format problem when inputting.

    v-bofeng-msft_0-1606879932329.png

     

    I assume that the real format of this string is:

    Part number: AAA000

    Description: Test1

    Qty: 10

    Part number: BBB000

    Description: Test2

    Qty: 5

    Part number: CCC000

    Description: Test3

    Qty: 12

    If so, please try this flow:

    1\My entire flow

    v-bofeng-msft_1-1606879932333.jpeg

     

    Step1:create three variables

    v-bofeng-msft_2-1606879932335.png

     

    Step2:Do until

    v-bofeng-msft_3-1606879932339.jpeg

     

    Reference Expression:

    1\ div(length(Split(uriComponentToString(replace(uriComponent(variables('TheString')), '%0A', '/n')), '/n')), 3)

    2\ Split(Split(uriComponentToString(replace(uriComponent(variables('TheString')), '%0A', '/n')),'/n')[sub(mul(variables('count1'),3),3)],':')[1]

    The Result

    v-bofeng-msft_4-1606879932345.png

    In addition,There is also a relatively simpler way to split a string by line.

    The point is to create A string whose value is a carriage return.

    1.JPG

    note:Enter a carriage return in the place I marked

    Then-Do until

    v-bofeng-msft_3-1606879932339.jpeg

    Reference Expression:

    1\

    div(length(split(variables('TheString'),variables('blank'))), 3)

     

    2\ 

    Split(split(variables('TheString'),variables('blank'))[sub(mul(variables('count1'),3),3)],':')[1]

     

    Best Regards,

    Bof

  • gennarodp Profile Picture
    294 on at

    Hello Bof,

    thanks for wour answer.

     

    You are very great with Power Automate !! 

     

    In the Step1, you  in "Inizialise variable", you insert text of mail including part numbers example (AAA000, BBB000, CCC000).

     

    Those values, are variable, and are not the same, in the different emails that i receive.

     

    Could explain me better this step ?

     

    Thanks

     

    Regards

  • gennarodp Profile Picture
    294 on at

    Hello Bof,

    i give you more elements.

     

    In specific, the text is similar to this:

     

    testxtestxtestxtestxtestx

    testxtestxtestxtestxtestx

     

    Part Number: AAA000

    Description: Test1

    Qty: 10

     

    testxtestxtestxtestxtestx

    testxtestxtestxtestxtestx

     

    Part Number: BBB000

    Description: Test2

    Qty: 20

     

    testxtestxtestxtestxtestx

    testxtestxtestxtestxtestx

     

     

    Part Number: CCC000

    Description: Test3

    Qty: 4

     

    Is there a method to extract in the text only the all strings that starts with "Part Number:" ?

     

    And then order those strings in: 

    Part Number1

    Part Number2

    PartNumber3

     

    Thanks

     

    Regards

  • Paulie78 Profile Picture
    8,422 Moderator on at

    Although it is possible to do this with with excellent help @v-bofeng-msft has given you, for emails like this, I would suggest taking a look at mailparser.io and using that to parse your email. It is so easy to do.

  • v-bofeng-msft Profile Picture
    on at

    Hi @gennarodp :

    Just add a variable named blank, and then modify the two Expressions.

    Please try this:

    2.JPG

    note:The omitted steps are in my previous soltuion

    1.JPG

    1\

    sub(length(split(variables('TheString'),'Part number:')),1)

    2\

    Split(split(variables('TheString'),'Part number:')[variables('count1')],variables('blank'))[0]

    The Result

    3.JPG

    Best Regards,

    Bof

  • gennarodp Profile Picture
    294 on at

    Hello @v-bofeng-msft ,

    thank you for your answer.

     

    But the space in the email can be variable, and the number of part number is variable (can be three, but also four, or one).

     

    For those reasons, i have asked you an variable that i use only when the field "Part Number" is find.

     

    Thank you very much.

     

     

  • Verified answer
    v-bofeng-msft Profile Picture
    on at

    Hi @gennarodp :

    I have improved the scheme. The problem you mentioned does not affect anything, you can test it.

    Test text:

    1.JPG

    The Result:

    2.JPG

     

    Best Regards,

    Bof

  • v-bofeng-msft Profile Picture
    on at

    Hi @gennarodp :

    The value of TheResult is blank when it is initialized, no need to fill in.

    Best Regards,

    Bof

  • gennarodp Profile Picture
    294 on at

    Hello Bof,

    thanks for yourn answer but doesnt't work 😞

     

    It extract to me only the first Part Number, and not others two.

     

    What could be the problem?

     

     

     

     

  • gennarodp Profile Picture
    294 on at

    Update: ok, it worksssss !!!!

     

    But the result is not fine separated:

     

    The result is as:

     

    Part Number 1 : AAA000Part Number 2 : BBB000Part Number 3 : CCC000

     

    How is there error ? 

     

    Why doesnt' separate it correctly ?

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 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard