Parker Software Ltd Homepage
Forum Home Forum Home > ThinkAutomation Business Process Automation > ThinkAutomation Version 4
  New Posts New Posts RSS Feed - Need help with RegEx in Repeating Block
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Need help with RegEx in Repeating Block

 Post Reply Post Reply
Author
Message
mitesh281 View Drop Down
Professional
Professional
Avatar

Joined: 24 Feb 2009
Location: India
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote mitesh281 Quote  Post ReplyReply Direct Link To This Post Topic: Need help with RegEx in Repeating Block
    Posted: 23 May 2019 at 1:37am
Hi, 

I want to process below format of an email. From Below email, I want to fetch each line of Name and Age of the students. There can be any number of names in an email. I have tried with the Repeating Block with  RegEx [^\n\r]*[\n\r]. However the problem is, it is collecting Summary and Date field as well. Can you help with a RegEx which fetch only Name and Age lines and stop at Summary line?

Email Format is as below,

Course Name: Test Course

Name:Test | Age:32

Name:Test1 | Age:31

Name:Test2 | Age:28

Summary: Test Summary

Date: Test Date


Thanks,
Mitesh
Back to Top
Daniel Horton View Drop Down
Admin Group
Admin Group
Avatar
Technical Support

Joined: 01 Jun 2009
Location: Stoke-on-Trent
Points: 351
Post Options Post Options   Thanks (0) Thanks(0)   Quote Daniel Horton Quote  Post ReplyReply Direct Link To This Post Posted: 24 Jun 2019 at 4:17am
Hi! 

Unfortunately in cases with repeating blocks you will need to take all fields from the email until you hit the new record. How you actually handle the values is optional within your Trigger Actions, as when using a Repeating Block you pass the individual blocks of data on to a separate Trigger (using Pass To against the Extracted Field - https://www.thinkautomation.com/help/repeatingblocks.htm?zoom_highlightsub=repeating%2Bblock) that handles the values. At this step, you can chose to ignore the parsing of the two fields mentioned (summary and date), so that they are not processed or used within the Trigger Actions area. 

So in essence you will need to include the two fields so that you can find the boundaries of your individual block and it knows what to look for to find the pattern that repeats. With your second trigger you can decide which data fields are actually used for further Trigger Actions.

Let us know if you have any further questions.
Best Regards,



Daniel James Horton

Technical Manager

Parker Software
Back to Top
mitesh281 View Drop Down
Professional
Professional
Avatar

Joined: 24 Feb 2009
Location: India
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote mitesh281 Quote  Post ReplyReply Direct Link To This Post Posted: 25 Jun 2019 at 9:40am
Hi Daniel,

Thank you for your reply.

In an email format which I mentioned "Name:Test | Age:32" is one block. So there are total three blocks in an example. There can be 'n' number of blocks of Name and Age. 

To fetch block of "Name and Age" I wrote this RegEx [^\n\r]*[\n\r] however this RegEx is also selecting Summary and Date from an email which is not correct block. 

I am looking for a RegEx which fetch only Name:Test | Age:32 block. 

Thanks,
Mitesh
Back to Top
Daniel Horton View Drop Down
Admin Group
Admin Group
Avatar
Technical Support

Joined: 01 Jun 2009
Location: Stoke-on-Trent
Points: 351
Post Options Post Options   Thanks (0) Thanks(0)   Quote Daniel Horton Quote  Post ReplyReply Direct Link To This Post Posted: 26 Jun 2019 at 1:43am
You could instead handle this with 3 triggers. Break out the section of from the first Name to the word Summary and pass that on to a second, in the second trigger perform your repeating block against just the Name and Age values, then pass the individual items on to your final trigger. In the final trigger you will just get one Name and Age value, so you can perform your task there with the data. 

I hope that makes sense and assists the situation for you.
Best Regards,



Daniel James Horton

Technical Manager

Parker Software
Back to Top
mitesh281 View Drop Down
Professional
Professional
Avatar

Joined: 24 Feb 2009
Location: India
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote mitesh281 Quote  Post ReplyReply Direct Link To This Post Posted: 28 Jun 2019 at 6:14am
Hi Daniel,

I have created three triggers as per your suggestion. First trigger will forward message to second trigger starting from Course Name upto Name and Age. In second trigger I have used repeating block to get the blocks of Name and Age line. I have used [^\n\r]*[\n\r] Regex to fetch blocks of Name and Age. From this trigger, I am passing blocks of Name and Age to third trigger. 

The problem is now, instead of three blocks of Name and Age, second trigger is passing 14 blocks to third trigger. Three actual blocks and 11 empty blocks. Is RegEx [^\n\r]*[\n\r] is correct to fetch the single line blocks?

Thanks,
Mitesh


Edited by mitesh281 - 28 Jun 2019 at 6:38am
Back to Top
Daniel Horton View Drop Down
Admin Group
Admin Group
Avatar
Technical Support

Joined: 01 Jun 2009
Location: Stoke-on-Trent
Points: 351
Post Options Post Options   Thanks (0) Thanks(0)   Quote Daniel Horton Quote  Post ReplyReply Direct Link To This Post Posted: 01 Jul 2019 at 3:04am
You could do it without Regex which would be simpler. Here is how but it will lose the Name tag at the start, which shouldn't be a problem as you have a divider of "|" which you can split based on with the single value. 

Use the following
'Look for' = Name: 
'Then look for' = *
Extract Until = End of line
Repeated Block = True

From my tests this gives you an individual object of "Test | Age:32" 

Best Regards,



Daniel James Horton

Technical Manager

Parker Software
Back to Top
mitesh281 View Drop Down
Professional
Professional
Avatar

Joined: 24 Feb 2009
Location: India
Points: 67
Post Options Post Options   Thanks (0) Thanks(0)   Quote mitesh281 Quote  Post ReplyReply Direct Link To This Post Posted: 02 Jul 2019 at 4:20am
Thank you Daniel for quick reply. I will try this solution and will update you.

Regards,
Mitesh
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 11.05
Copyright ©2001-2016 Web Wiz Ltd.

This page was generated in 0.047 seconds.