Regular Expressions

Examples of useful regular expressions supported by HCL Workload Automation.

This section gives some examples of useful regular expressions, together with a table that defines the expressions supported by HCL Workload Automation. Further information about regular expressions is also widely available in the Internet.

Useful regular expressions

The following table shows some useful regular expressions for use with the plan extractor, both for filtering jobs and job streams, and for configuring business unit names.

Table 1. Useful regular expressions
Requirement Regular expression Example
To obtain the same effect as using the "@"character in the Tivoli Workload Scheduler command line .* -JScpu .*

Used as a parameter to the plan extractor, filters for all job stream workstations.

To join different criteria in an "OR" relationship | (XYZ.*)|(.*ABC.*)

Filters for all items that begin with the string "XYZ or that contain the string "ABC" (regular expressions are case-sensitive).

To select objects that begin with one of several characters [˂the characters to be included>] [ABC].*

Filters for all items that begin with either "A", "B", or "C".

To select objects that do not begin with one of several characters [^˂the characters to be excluded>] [^ABC].*

Filters for all items that do not begin with either "A", "B", or "C".

To select objects in which certain characters appear a certain number of times ˂the character to be counted>{˂the character count>} A{3}.*

Filters for all items that begin with the string "AAA".

To select objects in which certain characters appear at least a certain number of times ˂the character to be counted>{˂the character count>} A{3,}.*

Filters for all items that begin with the string "AAA", "AAAA", "AAAAA", and so on.

To select objects in which certain characters appear at least a certain number of times, but not more than a certain number of times ˂the character to be counted>{˂the lower character count>,˂the upper character count>,} A{3,4}.*

Filters for all items that begin with the string "AAA", or "AAAA"; a string that began with "AAAAA" would not be selected.

Complex expressions

These individual regular expressions can be combined to make a complex expression, as shown in the following table.

Table 2. Complex expressions
Example requirement Regular expression
Select all strings that begin with "AA", "AB", "AC", "BA", "BB", "BC", "CA", "CB", or "CC", and also those that do not end in "X", "Y", or "Z". ([ABC]{2}.*)|(.*[^XYZ])
Select all strings that begin with "AA" followed by either one or more numbers or one or more letters, and then by the character "_". It can finish with any characters.

This would, for example, select the string AA11_XYZ76 and the string AAFGH_43KKK, but not the string AA8H_3232IHSDG, because this latter has both numbers and letters between the "AA" and the "_".

A{2}([0-9]+|[A-Z]+)_.*
Regular expressions supported by the plan extractor

The following tables provide full details of the regular expressions supported by the plan extractor.

Table 3. Regular expressions supported by the plan extractor: character
Syntax Filters for?
x The character x (regular expressions are case-sensitive)
\\ The backslash character
\0n The character with octal value 0n (0 ˂= n <= 7)
\0nn The character with octal value \0nn (0 ˂= n <= 7)
\0mnn The character with octal value \0mnn(0 ˂= m ˂= 3, 0 ˂= n ˂= 7)
\0xhh The character with hexadecimal value 0xhh
\uhhhh The character with hexadecimal value 0xhhhh
\t The tab character ('\u0009')
\n The newline (line feed) character ('\u000A')
\r The carriage-return character ('\u000D')
\f The form-feed character ('\u000C')
\a The alert (bell) character ('\u0007')
\e The escape character ('\u001B')
\cx The control character corresponding to x
Table 4. Regular expressions supported by the plan extractor: character classes
Syntax Filters for?
[abc] a, b, or c (simple class)
[^abc] Any character except a, b, or c (negation)
[a-zA-Z] a through z or A through Z, inclusive (range)
[a-d[m-p]] a through d, or m through p: [a-dm-p] (union)
[a-z&&[def]] d, e, or f (intersection)
[a-z&&[^bc]] a through z, except for b and c: [ad-z] (subtraction)
[a-z&&[^m-p]] a through z, and not m through p: [a-lq-z] (subtraction)
Table 5. Regular expressions supported by the plan extractor: predefined character classes
Syntax Filters for?
. Any character (might or might not match line terminators)
\d A digit: [0-9]
\D A non-digit: [^0-9]
\s A whitespace character: [ \t\n\x0B\f\r]
\S A non-whitespace character: [^\s]
\w A word character: [a-zA-Z_0-9]
\W A non-word character: [^\w]
Table 6. Regular expressions supported by the plan extractor: POSIX character classes (US-ASCII only)
Syntax Filters for?
\p{Lower} A lowercase alphabetic character: [a-z]
\p{Upper} An uppercase alphabetic character:[A-Z]
\p{ASCII} All ASCII:[\x00-\x7F]
\p{Alpha} An alphabetic character: [\p{Lower}\p{Upper}]
\p{Digit} A decimal digit: [0-9]
\p{Alnum} An alphanumeric character: [\p{Alpha}\p{Digit}]
\p{Punct} Punctuation: One of !"#$%&'()*+,-./:;˂=>?@[\]^_`{|}~
\p{Graph} A visible character: [\p{Alnum}\p{Punct}]
\p{Print} A printable character: [\p{Graph}]
\p{Blank} A space or a tab: [ \t]
\p{Cntrl} A control character: [\x00-\x1F\x7F]
\p{XDigit} A hexadecimal digit: [0-9a-fA-F]
\p{Space} A whitespace character: [ \t\n\x0B\f\r]
Table 7. Regular expressions supported by the plan extractor: classes for Unicode blocks and categories
Syntax Filters for?
\p{InGreek} A character in the Greek block (simple block)
\p{Lu} An uppercase letter (simple category)
\\p{Sc} A currency symbol
\P{InGreek} Any character except one in the Greek block (negation)
[\p{L}&&[^\p{Lu}]] Any letter except an uppercase letter (subtraction)
Table 8. Regular expressions supported by the plan extractor: boundary matchers
Syntax Filters for?
^ The beginning of a line
$ The end of a line
\b A word boundary
\B A non-word boundary
\A The beginning of the input
\G The end of the previous match
\Z The end of the input but for the final terminator, if any
\z The end of the input
Table 9. Regular expressions supported by the plan extractor: greedy quantifiers
Syntax Filters for?
X? X, once or not at all
X* X, zero or more times
X+ X, one or more times
X{n} X, exactly n times
X{n,} X, at least n times
X{n,m} X, at least n but not more than m times
Table 10. Regular expressions supported by the plan extractor: reluctant quantifiers
Syntax Filters for?
X?? X, once or not at all
X*? X, zero or more times
X+? X, one or more times
X{n}? X, exactly n times
X{n,}? X, at least n times
X{n,m}? X, at least n but not more than m times
Table 11. Regular expressions supported by the plan extractor: possessive quantifiers
Syntax Filters for?
X?+ X, once or not at all
X*+ X, zero or more times
X++ X, one or more times
X{n}+ X, exactly n times
X{n,}+ X, at least n times
X{n,m}+ X, at least n but not more than m times
Table 12. Regular expressions supported by the plan extractor: logical operators
Syntax Filters for?
XY X followed by Y
X|Y Either X or Y
(X) X, as a capturing group
Table 13. Regular expressions supported by the plan extractor: back references
Syntax Filters for?
\n Whatever the nth capturing group matched
Table 14. Regular expressions supported by the plan extractor: quotation
Syntax Filters for?
\ Nothing, but quotes the following character
\Q Nothing, but quotes all characters until \E
\E Nothing, but quotes all characters until \Q
Table 15. Regular expressions supported by the plan extractor: special constructs (non-capturing)
Syntax Filters for?
(?:X) X, as a non-capturing group
(?idmsux-idmsux) Nothing, but turns match flags on - off
(?idmsux-idmsux:X) X, as a non-capturing group with the given flags on - off
(?=X) X, via zero-width positive lookahead
(?!X) X, via zero-width negative lookahead
(?˂=X) X, via zero-width positive lookbehind
(?˂!X) X, via zero-width positive lookbehind
(?>X) X, as an independent, non-capturing group