Trigger Wizard

Added in v3.16

Trigger Pattern wizardA Trigger Wizard can be used to help build regular-expression-like patterns.  Wildcards for matching different types of text, such as digits, words, etc can be easily added from a dropdown menu.  Text from the server can be tested against the trigger to see if it matches and any subpatterns captured from the text are shown.  Multiple lines of text from the server can be "merged" and automatically create the pattern that matches both lines.

To get started with the Trigger Wizard, select a line of text from the server you wish to match using the "Text" dropdown box on the left, or type an example line into the Text box.

Next, select a portion of the text that can change and then select the type of text you wish to match from the "Match:" dropdown list below.

For example, if the server sends a line such as:

status: disconnected
status: error

then you would enter "status: disconnected" into the Text field, then select the "disconnected" portion of the text and select the "Match anything (*)" item in the Match dropdown.  This will convert the "Pattern" along the top to:

status: *

Next, enable the "Save captured subpattern" to capture the server status to the %1 variable.  This will cause parenthesis to be placed around the pattern, so now it will look like this:

status: (*)

Note that as you change the Text field, the Pattern will be changed to match what you enter.  Each wildcard will be shown in a different background color in both the Text field and the Pattern field and the Captured Subpattern list.  This will help you learn what your wildcards are matching.  You can click within the colored wildcard at any time to change the type of wildcard being used.

At the bottom of the screen, the actual Regular Expression of the pattern will be shown for your reference.  However, you can only use the Pattern Wizard to create zScript Trigger Patterns and not Regular Expressions directly.  If you click the Wizard tab for a Regular Expression Trigger, only a simple testing box and some help on common regular expressions will be shown.

Merging Lines

One powerful feature of the Pattern Wizard is the ability to examine multiple lines of text from the server and create a trigger pattern with the proper wildcards that will match all of the lines.  To use this feature, first select a line of text from the server using the "Text" dropdown menu, or type a line into the Text field directly.  Press the Up button just to the right of the "Merge" button to copy this text verbatim into the Pattern field.  Next, select a second line from the server using the "Text" dropdown, or type a line into the Text field directly, then click the "Merge" button.  This will create a new Pattern that matches the previous line and the new line.

You can continue selecting lines of text from the server or entering lines manually and clicking the "Merge" button to continue modifying the pattern to match all of the lines you enter.

You can also use the Undo and Redo buttons to fix any problems that might occur during the process.

Add comment

Login or register to post comments