Conditions.bool-primary-like-regex

Returns True if a value matches a regular expression

Format

expression [ NOT ] LIKE_REGEX Pattern [FLAG Options]

Remarks

Checks if a string value matches a given regular expression.

Pattern is a regular expression pattern. For more information on regular expression patterns, refer to Regular Expressions.

If specified, the Options argument changes the pattern matching behaviour. For more information on regular expression options refer to Regular Expression Option Flags

The LIKE_REGEX predicate returns Unknown if any of the operands are NULL.

Example:

Example 1: Find all badly formed UK postal codes (assumes CDBObject has a custom field called Postcode).

SELECT FullName FROM CDBObject WHERE Postcode NOT LIKE_REGEX '[[:alpha:]]{1,2}[[:digit:]]{1,2}[[:alpha:]]? [[:digit:]][[:alpha:]]{1,2}' FLAG 'i'

Example 2: Find all well formed US ZIP codes (assumes CDBObject has a custom field called Zipcode).

SELECT FullName FROM CDBObject WHERE Zipcode LIKE_REGEX '[[:digit:]]{5}(-[[:digit:]]{4})?'

If you reference system status tags in your ST programs, you need to prefix the names of those system status tags with an additional caret '^' escape character. This escapes the reserved caret '^' character that is used at the start of the names of system status tags (also known as 'status attributes') (see Access System Status Information).

For example:

VAR

sServerStateTime AT %M(^^<server name>.ServerStateTime): DATE_AND_TIME;

END_VAR


Disclaimer

Geo SCADA Expert 2019