System Debug Reference Manual (32650-90888)

Appendix A 531
Patterns and Regular Expressions
Literal Expressions (Match Exactly These Characters)
A Patterns and Regular Expressions
Several System Debug commands apply the concept of pattern matching. Commands such
as CMDLIST, ENVLIST, FUNCLIST, MACLIST, PROCLIST, SYMLIST, and VARLIST
support pattern matching in order to select which commands, functions, macro names,
procedure names, symbol names, or variables are to be displayed.
Regular expressions are used to find or match some specified text within a large amount of
surrounding text. A typical example is to find all lines in a file that contain the word
"computer."
In a similar manner, the FILTER environment variable is used to selectively filter all
System Debug output, displaying only those lines that match the pattern or regular
expression.
A regular expression can be a single character, like the letter "c" or a more elaborate
construct built up from simple things like the string "computer".
Literal Expressions (Match Exactly These Characters)
Any literal character, such as "c", is a regular expression and matches that same character
in the text being scanned. Regular expressions may be concatenated: a regular expression
followed by another regular expression forms a new regular expression that matches
anything matched by the first followed immediately by anything matched by the second. A
sequence of literal characters is an example of concatenated expressions. For example,
"c0000000" or "computer" is a pattern that matches any occurrence of that sequence of
characters in the line it is being compared against.
A regular expression is said to match part of a text line if the text line contains an
occurrence of the regular expression. For example, the pattern "aa" matches the line "aabc"
once at position 1, and the line "aabcaabc" in two places, and the line "aaaaaa" in five
(overlapping) places. Matching is done on a line-by-line basis; no regular expression can
match across a line boundary.
Metacharacters
In order to express more general patterns than just literals, some specific characters have
been defined. For example, the character "." as a regular expression matches any single
character. The regular expression "a.b" matches "a+b", "aZb", and similar strings.