Patterns can contain several special character for wild-card matching:
To save any part of the pattern to the %1..%99 parameters, enclose the part of the parameter in parenthesis.
In specifying a range, you can list specific characters such as [abc] or you can use a range [a-c].
To use a wild card character in the pattern string itself, precede the special character with the ~ quote character. For example, the pattern ~[test~] will match the string [test] rather than being interpreted as a range wild-card pattern. Note that the quote character can be changed in the Special Characters Preferences.
To match a blank line, use the $ pattern by itself. To match multiple lines include $ in the middle of the pattern to match the line boundary.
You can also include variables in your pattern, and the name of the variable will be replaced with its value before the pattern match is performed.
The &VarName syntax deserves a bit more explanation. It is used to store a matched pattern into a variable directly. For example, if you have a trigger:
and the server displays
Then the value "offline" is automatically put into the @Error variable with no further action on your part. By default, the &VarName uses the * wildcard. To specify a different wildcard, insert the wildcard just after the & character. In the above example, when the server says
the @Error variable would then contain the string "123". To restrict the trigger to just match a word, change the trigger to:
Now the "Status: 123" will not match the trigger. You can use any of the wildcard specifiers, and can also use the square brackets [] to define your own wildcard range.
Sometimes there is alphabetic text in the pattern after the string you want to capture. To delimit this from the variable name, place the variable name in {} brackets. For example, to capture
you would use a trigger:
which will only match digits and will properly set the @Ping variable to 1000.
The &VarName syntax also works with database records and record variables. If you have a record variable @Status and want to set the Ping property, you would use a trigger of:
NOTE: The patterns matched by the &VarName syntax still count towards the %1..%99 variables and can still be accessed in that manner. So, in the example:
it will automatically set the @Ping and @avgPing variables, and the %1 and %2 parameters will also still be set just as if you had put parenthesis around the &VarName. This is important when you mix &VarName and () in the same trigger. Always count the &VarName as if it also has a parenthesis around it.
Add comment