Logical and arithmetic expressions
Logical and arithmetic expressions can be used in
SHOW clauses and
The following topics are covered in this section:
WHERE clauses, the following values are considered False:
None (for example, missing attribute)
All other values are considered True. This allows simple
WHERE clauses that choose only useful values. For example, to find all Software Instance nodes with a populated version:
The following logical and arithmetic expressions are supported:
For a single word search, the condition is true if
For a multi-word search:
When used in a
Regular expression match
Operator precedence works as you would expect. Parentheses
) are used to explicitly group operations. Otherwise, in arithmetic expressions,
/ take precedence over
-. In logical expressions,
OR has lowest precedence, followed by
AND, followed by
NOT, followed by all the other operators. i.e. this expression
is equivalent to
Logical expressions in SHOW clauses
Logical expressions can be used in
SHOW clauses. To do so, they must be enclosed in parentheses, e.g.
The behavior of
OR in returning one of their input parameters can be useful in handling missing attributes, to avoid output of "None" when an attribute is not available, for example:
Logical expression name binding
Logical expressions can be bound to names. For example:
Using a regular expression
The MATCHES condition enables you to search by matching against a regular expression (or regex), a pattern that matches various text strings. For example,
A[0-9]+ matches any string that consists of the letter A followed by one or more digits.
Regular expressions have a defined syntax that enables you to define complex matching patterns. BMC Discovery uses the Python implementation; for full syntax and details of use, consult the Python documentation. For more information, see https://docs.python.org/2/library/re.html.
The following table lists a few of the matching characters that you can use when constructing regular expressions. An ordinary character, or a sequence of characters, matches that character or string.
A dot matches any single character.
A caret matches characters at the start of the string.
A dollar sign matches characters at the end of the string.
An asterisk matches 0 or more repetitions of the preceding regex. For example, ab* matches "a," "ab," or "a" followed by any number of "b"s.
A plus sign matches one or more repetitions of the preceding regex. For example, ab+ matches "a" followed by any nonzero number of "b"s; it does not match just "a."
A question mark matches 0 or 1 repetitions of the preceding regex. For example, ab? matches either "a" or "ab."
Square brackets indicate a set of characters that can be matched. For example, "asdf" matches any of the characters "a," "s," "d," "f."
The vertical bar separates regular expressions, any or which can be matched. For example, A|B matches either A or B.
The backward slash followed by any special character matches the special character itself.