In this section we look at a simple regular expression pattern that selects all hosts whose names start with Host. The completed expression is Host.*. This expression contains two special characters:
The final expression, Host.*, results in matching any strings that start with Host and match any of the following host names:
• |
• |
However, the following host names do not match this expression:
We now take a look at a simple pattern that matches a group of similar text strings. A common pattern for selecting Windows® drive names is C:.*. A typical usage of this expression is in the Excluded Drives property of the WindowsAgent.
Unlike in a simple file matching filter, C:*, the equivalent regular expression requires a period between the colon ‘:’ and the asterisk ‘*’: C:.*.
Next, we build a regular expression that selects all hosts whose name include the string Host, not just the ones that start with Host. To do that, simply add a prefix to the above expression, Host.*, resulting in .*Host.*.
This expression matches any hosts that include Host, but not necessarily begin with it. That is because the prefix .* translates to any combination of zero or more characters appearing before the string Host. The expression matches each of the following host names:
• |
• |
• |
DBHost-9000, but not DBHst-9000 |
Choosing the second option, the resulting regular expression is: [C-H]:.*. This means, any letter in the range and including ‘C’ through ‘H’, followed by a colon ‘:’, and optionally by more characters.
Using regular expressions you can define a pattern to match a multi-character pattern. For example, you can write a regular expression to match all hosts whose names contain Host and are followed by exactly two digits. That means you want to match the following strings:
• |
• |
The expression that matches this pattern is: Host[0-9][0-9].
Going further, you can write an expression that matches all hosts whose names contain Host, followed by exactly two digits, and optionally a lowercase letter. That means you want to match the following strings:
• |
• |
The expression that matches this pattern is: Host[0-9][0-9][a-z]?.
• |
The plus sign ‘+’ means one or more times. For example, case[0-9]+ matches case1, case12345, but not simply case. |
• |
{3} occur exactly three times. |
• |
{2,4} occur at least two times and as many as four times. |
• |
{3,} occur at least three times up to infinity. |
© ALL RIGHTS RESERVED. 利用規約 プライバシー Cookie Preference Center