Using wildcards
Supported wildcards
Matches: | |
---|---|
* | Any number of characters (zero or more). |
? | Any one character. |
# | Any one digit from 0 through 9. |
[characters] | Any one of the characters in the list or range specified here. |
[!characters] | Any one character not included in the list or range of characters specified here. |
Matching characters in a list
To match characters in a list, enclose the characters between square brackets with no spaces or other delimiters between characters (unless you want the space character to be part of the list).
[1, 2, 3, A, B, C] represents the characters 1, comma, space, 2, 3, A, B, and C. The redundant occurrences of the space and comma are ignored.
[123ABC] represents the characters 1, 2, 3, A, B, and C (with no space or comma character).
Matching characters in a range
To match characters in a range, separate the lower and upper bounds with a hyphen, as in [1-5]. Always specify the range in ascending sort order (A-Z rather than Z-A).
When you specify multiple ranges, you don’t have to separate them with anything.
[1-5A-C] contains the ranges 1-5 and uppercase A-C.
A range specified in ascending order will produce a valid pattern string.
Matching special characters
To match one of these characters, include it in a characters list:
- Hyphen
-
- Question mark
?
- Asterisk
*
- Number sign
#
- Open bracket
[
Be sure to place the hyphen at the beginning of the list; if you’re using the [!characters] format, the hyphen immediately follows the exclamation point, as in [!-123]. The other characters can appear anywhere in the characters list.
[-?A-Z] matches the hyphen, the question mark, and any uppercase letter from A through Z.
To match one of these characters, place the character anywhere within your wildcard specification except in a characters list or range:
- Comma
,
- Close bracket
]
- Exclamation mark
!
!,[1-6] matches the exclamation point, the comma, and any digit from 1 through 6.