How-To

Back to How-To Guides

Trigger Commands & Regular Expressions

What are Regular Expressions, and how to use them in your triggers.

This guide is applicable to v1.1.0 of the app or greater.

Regular Expressions are a way to allow strings to be matched with a wildcard-like pattern matching syntax. They can get quite complicated when dealing with long expressions, but this guide will hopefully help you understand a few basics, as well as cover the most general scenarios that Screenabl will come across from various hardware.

Expressions can be written to match exact phrases, ignore certain parts, match specific segments or characters. Most of the systems which will be communicating with Screenabl would use fairly basic commands so shouldn't be too complicated.

Syntax Examples

Each example below has a "Open in visualiser" link to https://regex-vis.com which is a great Regular Expression visualiser to see a human readable version of the expressions, as well as the ability to test some input strings (test strings have already been added to each example below).

  • Adding normal characters a-z or 0-9 will match those chacters exactly.
  • Adding a . character which match any single character.
  • Characters can be matched for either case by wrapping them in brackets [hH] instead of just having the one character.

NOTE: The visualiser has ^ and $ at the start/end of the expressions which are just used to specify that the strings must start and end with the pattern. The Screenabl app automatically adds these to the expressions you use. So DO NOT add them into your expressions when adding them into the app.

Eg/

GPO ...H.
Open in visualiser

Will match any string starting with "GPO ", Any Character, Any Character, Any Character, "H", Any Character.

Matches: "GPO LLLHL", "GPO LHHHL", "GPO HLHHL"

Non-Matches: "GPO LLHLH", "GPO LHHLL", "GPO HHHLH", "gpo LLLHL", "GPO lllhl", "gpo LLLhL"

GPO .[hH]...
Open in visualiser

Will match any string starting with "GPO ", Any Character, "h" or "H", Any Character, Any Character, Any Character.

Matches: "GPO LHLHL", "GPO lhlhl"

Non-Matches: "GPO LLHLH", "GPO LLHLL", "GPO llhlh", "gpo LHLHL"

(gpo|GPO) ..H..
Open in visualiser

Will match any string starting with "GPO" or "gpo", a " ", Any Character, Any Character, "H", Any Character, Any Character.

Matches: "GPO LLHHL", "gpo LLHHL"

Non-Matches: "GPO LLLLH", "GPO LHlLh", "gpo LLLLH", "gpo LHlLh"

(gpo|GPO) ..[hH]..
Open in visualiser

Will match any string starting with "GPO" or "gpo", a " ", Any Character, Any Character, "h" or "H", Any Character, Any Character.

Matches: "GPO LLHLL", "GPO LLhLL", "gpo LLHLL", "gpo LLhLL", "GPO llhhl"

Non-Matches: "GPO LLLLH", "GPO lllhl", "gpo LLLHL", "gpo LLLhL"

MIX 9 1:1
Open in visualiser

Will match any string "MIX 9 1:1" exactly

Matches: "MIX 9 1:1"

Non-Matches: "MIX 9 1:0", "MIX 2 1:1", "MIX 2 1:0", "MIX 9 1:2", "MIX 9 1:11", "MIX 9 1:01", "MIX 9 2:1", "MIX 9 1:1 ", "MIX 9 1:1 2:0", "GPO HHLHH"

MIX 9 1:(\d)
Open in visualiser

Will match any string starting with "MIX 9 1:" and then any single digit.

Matches: "MIX 9 1:0", "MIX 9 1:1", "MIX 9 1:9"

Non-Matches: "MIX 9 2:0", "MIX 9 1:H", "MIX 9 1:11", "MIX 2 1:0"

MIX 9 1:(\d+)
Open in visualiser

Will match any string starting with "MIX 9 1:" and then any digits (1 or more, non-decimal).

Matches: "MIX 9 1:0", "MIX 9 1:1", "MIX 9 1:12345"

Non-Matches: "MIX 9 2:0", "MIX 2 1:0", "MIX 9 1:H", "MIX 9 1:11 2:0", "MIX 9 1:12345 "

MIX 9 .*(?=1:0).*
Open in visualiser

Will match any string which starts with "MIX 9 " and has "1:0" anywhere in the string.

Matches: "MIX 9 1:0", "MIX 9 1:0 2:0", "MIX 9 1:0 2:0 3:0", "MIX 9 2:0 1:0"

Non-Matches: "MIX 9 2:0", "MIX 9 1:H", "MIX 2 1:1", "MIX 2 2:0 3:0"

MIX 9 .*(?=1:(\d+)).*
Open in visualiser

Will match any string which starts with "MIX 9 " and has "1:" followed by digits anywhere in the string.

Matches: "MIX 9 1:0", "MIX 9 1:1", "MIX 9 1:12345", "MIX 9 1:12345 2:0", "MIX 9 1:12345 2:0 3:0", "MIX 9 2:0 1:1"

Non-Matches: "MIX 9 2:0", "MIX 9 1:H", "MIX 2 1:0", "MIX 2 2:0 3:0"

MIX 9 (?!.*1:0).*
Open in visualiser

Will match any string which starts with "MIX 9 " and DOES NOT HAVE "1:0" anywhere in the string.

Matches: "MIX 9 2:0", "MIX 9 3:0", "MIX 9 2:0 3:1"

Non-Matches: "MIX 9 1:0", "MIX 9 2:0 1:0 3:0"

MIX 9 (?!.*1:(\d+)).*
Open in visualiser

Will match any string which starts with "MIX 9 " and DOES NOT HAVE "1:" followed by digits anywhere in the string.

Matches: "MIX 9 2:0", "MIX 9 3:0", "MIX 9 2:0 3:1"

Non-Matches: "MIX 9 1:0", "MIX 9 1:1", "MIX 2 2:0", "MIX 9 2:0 1:0 3:0"

DELAY:(\d+)
Open in visualiser

Will match any string starting with DELAY:" and then any digits (1 or more, non-decimal).

Matches: "DELAY:0", "DELAY:25", "DELAY:76", "DELAY:100"

Non-Matches: "DELAY:S", "delay:25"

In the Screenabl app, the Progress Build Up control has the ability to specify a dynamic value for certain trigger types. The last example DELAY:(\d+) can be used as a guide and be adjusted specifically in the app to use {"{val}"} where you want to read the specific value to be used. Eg/ DELAY:{"{val}"}. Behind the scenes, Screenabl will automatically replace any {"{val}"} with (\d+), thus matching the number value and setting it as the dynamic value.

Note the DELAY:{"{val}"} expression will not work in the RegEx visualiser.

How to use them in the app?

Regular expressions can be used for ANY TCP/UDP trigger in the Screenabl app.

When adding a trigger you can simply choose "Regular Expression" from the Command format and then enter the command as a regular expression string.

As stated above, you DO NOT need to include the ^ or $ at the start/end of a any regular expression you're using as the Screenabl app automatically adds these to the expressions you use (they match the start/end of the string).

Below is an example from within the app using one of the Regular Expressions from the above list:

Regaulr Expression in the app

This would match any incoming command which started with "GPO" and then had either "h" or "H" on the 2nd pin. Eg/ GPO xhxxx or GPO xHxxx

Where they're used

The main reasons where Regular expressions are used are when connecting to Axia systems (as the trigger command received contain statuses for ALL pins), and when setting up delay units with a dynamic trigger pattern. For more information on either of these, please check out the related articles below.

Back to Top