Workflow Soluiton

 View Only
  • 1.  Extracting Text by Pattern

    Posted Nov 20, 2018 05:29 AM

    Hi,

    I have a piece of text that I'm capturing from an email which looks like the following:

     

    Order Number: A123

    Details: This is an alert from system 1

    Issues:

    Issue 1 is A

    Issue 2 is B

    Issue 3 is C

     

    Order Number: B123

    Details: This is an alert from System 2

    Issues:

    Issue 1 is 1

    Issue 2 is 2

     

    End

     

    I've got an array which has the order number it in and then I'm using the For Each Element in Collection

    This then has a Extract Text by Pattern where its setup to start with the Array Variable, ie the order number, and then use the following pattern as the end looking for "Issues:"

     

    So I basically get the result:

    Details: This is an alert from system 1

     

    This works great the first item in the array, but when it goes around the loop again it find the next order number so B123 fine, however when it searches for the end text I'm guessing it finds the first Issues: and seems to therefore not bring back any data, I assumed it would carry forward down the email from the Order ID but I don't think it is, I had a look at the Extract Text from Text but you cant use a variable as the begin location as its looking for a number and I want to use a text variable.

     

    Am I missing something obvious here?

     

    Thanks in advance :)



  • 2.  RE: Extracting Text by Pattern

    Posted Nov 20, 2018 05:47 AM

    If you've got the position of each "Order Number" you could grab the text between those positions then do some manipulation on the string.

    ---

    Is this related to Extracting first part of a variable?

    ---

    Article: Workflow - Tag Finder

    Forum: Parsing text from an email | Extracting Text to different variable from a Email body

    Component: Extract Text By Pattern



  • 3.  RE: Extracting Text by Pattern

    Posted Nov 20, 2018 06:01 AM

    Hi,

    Thanks for your reply :)

    So i know that the Order id will always be 4 characters but the list under Issues could be just a couple of lines or it could be 20-30 lines so I won't know exactly where it will be in the text each time?

    So how would i grab between those positions as I need it to read down from the Order ID to get the right message? I wondered about trying to split it into separate collections but you need a delimiter and I would want to split by a pice of text? 

     

    Thanks again :)

     



  • 4.  RE: Extracting Text by Pattern

    Posted Nov 20, 2018 07:51 AM

    Well I had a little think about this over a coffee and then decided I was over thinking it and that it was way simplier to just do another Extract from the already Extract text so I setup a new Extract to look at the variable and the look for the next record ID but now that just doesn't return anything ?

    So Im feeding in:

    Order Number: A123

    Details: This is an alert from system 1

    Issues:

    Issue 1 is A

    Issue 2 is B

    Issue 3 is C

    Order Number: B123

    Details: This is an alert from System 2

    Issues:

    Issue 1 is 1

    Issue 2 is 2

    End

     

    And then asking the next Extract to Start with B123 so I would have expected it to bring back "Details: This is an alert from System 2" but it doesn't bring anything back, if I change the Start with to A123 then it works fine ? Am i missing something this should be simple extract why would not find A123 ok but not B123? ???

    Thanks in advance :)



  • 5.  RE: Extracting Text by Pattern
    Best Answer

    Posted Nov 20, 2018 08:07 AM

    You could use a combination of Index Of Text Within Text and Extract Text From Text



  • 6.  RE: Extracting Text by Pattern

    Posted Nov 20, 2018 08:19 AM

    Thank you so much, yes I should have gone back to the Index of Text now I have my managed to get order IDs so that's perfect I just tested it and it worked perfectly

    Thank you again for your help pushing me in the right direction, much appreciated :)