Regular expressions
Characters
Use the following expressions to match individual letters, digits or whitespace characters.
Character |
Description |
Example |
Sample match |
|---|---|---|---|
|
One digit from 0 to 9 |
|
file_25 |
|
Word character: ASCII letter, digit or underscore |
|
A-b_1 |
|
Whitespace character: space, tab, newline, carriage return, vertical tab |
|
a b c |
|
One character that is not a digit as defined by |
|
ABC |
|
One character that is not a word character as defined by |
|
*-+=) |
|
One character that is not a whitespace character as defined by |
|
Yoyo |
|
Any character except line break |
|
abc |
|
Any character except line break |
|
anything |
|
A period (special character: needs to be escaped by a |
|
a.c |
|
Escapes a special character |
|
.*+? $^/ |
|
Escapes a special character |
|
[{()}] |
Character classes
Character |
Description |
Example |
Sample match |
|---|---|---|---|
|
One of the characters in the brackets |
|
One uppercase vowel |
|
One of the characters in the brackets |
|
Tap or Top |
|
Range indicator |
|
One lowercase letter |
|
One of the characters in the range from x to y |
|
GREAT |
|
One of the characters in the brackets |
|
One of either: A,B,1,2,3,4,5,w,x,y,z |
|
One of the characters in the range from x to y |
|
Characters in the printable section of the ASCII table. |
|
One character that is not x |
|
A1! |
|
One of the characters not in the range from x to y |
|
Characters that are not in the printable section of the ASCII table. |
|
One character that is a digit or a non-digit |
|
Any characters, including new lines, which the regular dot doesn’t match |
|
Matches the character at hexadecimal position 41 in the ASCII table, i.e. A |
|
ABE |
Logic
Logic |
Description |
Example |
Sample match |
|---|---|---|---|
|
Alternation / OR operand |
|
33 |
|
Capturing group |
|
Apple (captures “pple”) |
|
Contents of group 1 |
|
regex |
|
Contents of group 2 |
|
12+65=65+12 |
|
Non-capturing group |
|
Apple |
Quantifiers
You can append one of the following expressions to any character, character class or capturing group to match multiple occurrences.
Quantifier |
Description |
Example |
Sample match |
|---|---|---|---|
|
One or more |
|
Version 7.30 |
|
Exactly three times |
|
ABiC |
|
Two to four times |
|
156 |
|
Three or more times |
|
regex_tutorial |
|
Zero or more times |
|
AAACC |
|
Once or none |
|
plural |
Example for system names
Assuming we have the system name B01.01F.AHU01_SUP_TS_AI that is consisting of the following segments:
Segment |
Description |
Meaning |
|---|---|---|
B01 |
Building / object |
Building 01 |
01F |
Location / floor |
1st floor |
AHU01 |
System / trade |
Air handling unit no. 1 |
SUP |
System section |
Supply air |
TS |
Component / function |
Temperature sensor |
AI |
Data point type |
Analog input |
You can write different regular expressions to match different kinds of system names.
Example |
Description |
|---|---|
|
This matches any data point in any building. |
|
This matches any data point on floors 1–3 in building 1. |
|
This matches any supply air or exhaust air data point in building 1. |
Note
To write and test regular expressions more easily, you can use external tools, such as regex101. Make sure to select the “Java” flavor.