Character | Meaning |
---|---|
| | Divides an expression into branches and then the overall expression matches any string, which matches any of the branches. For example, "Sam|Carol" matches all fields, which contain either or both of the strings "Sam" or "Carol". For information on how this character behaves differently when used with Like, see Like Operator. |
(xxxx) | Characters in parenthesis are treated by the subsequent special character the same as a single character is treated. For example, "abc*" matches "abc", abcc", and abccc", whereas (abc)* matches "abc", "abcabc", and "abcabcabc". |
* | Any character or group followed by "*" matches zero or more occurrences of the previous character or group in a string. Thus "Sam*y" matches "Say" (zero occurrences of "m"), "Samy" (one occurrence of "m"), "Sammy" (two occurrences of "m"), and "Sammmy" (three occurrences of "m"). In the same way, "Rin(tin)*" matches "Rin", "Rintin", "Rintintin", and "Rintintintin". |
+ | Any character or group followed by "+" matches one or more of that character or group in a string. "Sam+y" does not match "Say" but matches "Samy", "Sammy", "Sammmy", and so on. "Rin(tin)+" does not match "Rin" but matches "Rintin", "Rintintin", "Rintintintin", and so on. |
? | Any character or group followed by "?" matches either zero or one of that character or group in a string. So, "Sam?y" matches either "Say" or "Samy" but not "Sammy". "Rin(tin)?" matches "Rin" or "Rintin". |
{n,m} | Two numbers separated by a comma and enclosed in curly brackets, "{ }", can be used to specify a set or class of repetitions of the previous character or group. The first number indicates the minimum number of repetitions, and the second number indicates the maximum. The second number is optional. If it is omitted, there is no upper limit for repetitions. For example, "Sam{0,2}y" matches "Samy", "Sammy" but not "Sammmy". "Rin(tin){2}" does not match "Rintin" but matches "Rintintin" and "Rintintintin". |
[xxxx] | A sequence of characters enclosed in square brackets, "[ ]", constitutes a set. It normally matches any character within the sequence. Thus "Pa[tml]" matches "Pat", "Pam", or "Pal". If the sequence begins with a '^', the set or class matches any character not in the sequence. Thus "Pa[^tml]" matches any three-character sequence starting with "Pa" and ending with any character except 't', 'm', 'l'. |
[x-y] | Two characters separated by '-' represents a set or class, or a full list of ASCII characters between them. Thus, "Pa[0-9]" matches any three-character string starting with "Pa" and ending with a digit. "Pa[^0-9]" matches any three-character string starting with "Pa" and ending with anything except a digit. You can use a literal hyphen, caret, or square bracket in a set or class. The carat is treated as special only if it is the first character after the left bracket (in any other place it is treated literally). The hyphen is treated literally if it is either the first character (or second, if the carat is the first character), or last character in the set. The right bracket is treated literally (not special) if it is the first character (or second, if the carat is the first character) in the set. |
- (hyphen) | This character has no special meaning outside of a set or a class. |
. (period) | This character matches any single character. Thus "S.m" matches "Sam", "Sbm", "Scm", etc. A period can be followed by "*" to mean zero or more occurrences of any character, by "+" to mean one or more occurrences of any character and by "?" to means zero or one occurrences of any character. |
\ | A backslash followed by any character matches that literal character. For example, "Sam\." matches "Sam." unlike the expression "Sam.", which matches any four character string starting with "Sam" because '.' matches any character. To use a literal backslash character, enter it twice: "\\". |
^ | The caret matches the beginning of a field. Thus "^Sam" matches the string "Sam" only when it is at the beginning of a field. For example, "^am" matches "amplitude" but not "example". |
$ | The dollar sign matches the end of a field. Thus "Sam$" matches the string "Sam" only when it is at the end of a field. For example "am$" matches "slam" but not "tramp". To match a literal dollar character, use "\$". To match a blank string, use "^$". |