4 Replies Latest reply: Jun 8, 2016 8:12 AM by Justin J. Wang RSS

    Dynamic Traps

    Justin J. Wang

      Hey, guys:

      How could we use monarch to set up dynamic traps to recognize different templates? We have a text file consisting of contiguous templated letters, and would like to pick up an account number, and certain keywords in the body.

      The challenge is that sometimes the account number is preceded by:
      Account No.:
      and other times,
      PAT ACC NO:,
      MED REC#:

      The position of keywords we'd like to trap are at different locations depending on the template.


        • Re: Dynamic Traps
          Olly Bond

          Hello Justin,


          As long as you are on v13, the character list trap should help you here. Define a trap with the different optional letters in each column.


          Best wishes,



          • Re: Dynamic Traps
            Austin Perkins



            You could use Regular Expression traps if you are on v13. You could essentially setup three different append templates, which each one looking for:

                 1) Account No.:

                 2) PAT ACC NO:

                 3) MED REC#:


            The regular expression trap being (and selecting Explicit Capture from the options):

                 1) Account\s\w\.\:\s(?<Account>[0-9]+)       - Assuming the account numbers are numeric - you can lookup the regex syntax online

                 2) PAT\sACC\sNO\:\s(?<PatAccNo>[0-9]+)

                 3) MED\sREC\#\:\s(?<MedRecNo>[0-9]+)


            There are much smarter people in this forum that can rip that syntax apart but I believe it would work fine in your case. The good thing about the regular expression trap is that it will find it anywhere in the file and pull the entire length of the data if your target varies in length. It won't hurt anything to have all three of these in your template because only one should apply per file.


            Let me know if you have any questions.




            • Re: Dynamic Traps
              Joe Meree

              Hi Justin,

              I'm finding that you can sometimes avoid multiple models in processing a document with regular expressions in Monarch Classic or Data Prep Studio (both new in Monarch Complete v13).  Sometimes the work is too complex for that and If you want to dynamically invoke another model based on what's in the current document, you can do that in Datawatch Automator.  If you let me know where you're based, I can connect you with someone in your area to explore this.

              Joe Meree

              Solutions Architect, Datawatch

              • Re: Dynamic Traps
                Justin J. Wang

                Thank you all for your suggestions and taking the time to reply.  It sounds like upgrading to v13 and using regex/other features is the way to go.