![]()
Built in pattern matching provides a versatile tool for string comparisons. The pattern-matching features allow you to use wildcard characters, such as those recognized by the operating system, to match strings. The wild card characters and what they match are shown in the following table:
| Character(s) in pattern | Matches in expressiong> |
| ? | Any single character |
| * | Zero or more characters |
| # | Any single digit (0-9) |
| [charlist] | Any single character in charlist |
| [!charlist] | Any single character not in charlist |
A group of one or more characters (charlist) enclosed in brackets ([ ]) can be used to match any single character in expression and can include almost any characters in the ANSI character set, including digits. The special characters, left bracket ( [ ), question mark (?), number sign (#), and asterisk (*) can be used to match themselves directly only by enclosing them in brackets. The right bracket ( ] ) cannot be used within a group to match a group to match itself, but it can be used outside a group as an individual character.
In addition to a simple list of characters enclosed in brackets, charlist can specify a range of characters by using a hyphen (-) to separate the upper and lower bounds of the range. For example, [ A-Z ] in uppercase letters in the range A through Z. Multiple ranges are included within the brackets without any delimiting. For example, [ a-zA-Z0-9 ] matches any alphanumeric character.
Other important rules for pattern matching include the following:
![]()
Bug tracking doesn't have to be complicated | Help | Site Map