A pattern is a string which may contain the following special characters:
* |
Matches any sequence of characters in string, including a null string. |
? |
Matches any single character in string. |
! |
if the pattern is starting with this character then the pattern match will be case-sensitive. In this case the starting character is excluded from the match. |
( |
This position within the pattern is matching the start of a word, either beginning with a letter or a digit. |
) |
This position within the pattern is matching the end of a word, either ending with a letter or a digit. |
\x |
Matches the single character x. This provides a way of avoiding
the special interpretation of the characters ()*!?\ in
pattern. Also the blank character will be protected from a
special interpretation.
|
Pattern matching is in general case-insensitive, except if the pattern is
starting with the special character !
.
Also the blank character will be interpreted as a special character (if not protected), it is matching any number of blank characters, but not the empty string. But if a separating character (e.g. a comma) is adjacent to a blank character, also an empty string will match. In this way mistakes in spelling can be compensated. A protected blank character (preceded by a backslash) will match exactly one blank character.
Furthermore the following special rule applies: a parenthetical
expression – e.g. "(J*)"
– will not
match any string which contains blanks or separating characters.
Polgar, J*
This pattern can match the following strings: "Polgar, J"
,
and "Polgar, Judit"
.
A?erba?h
This can match the following names:
"Averbakh"
(English spelling), and "Awerbach"
(German spelling).
Kasparov*
This can match, among others, the following strings:
"Kasparov"
, "Kasparova"
,
"Kasparov, Gary"
, and "Kasparova, Tatiana"
.
Kasparov*)
This can match the same strings as in the latter case, because all
these strings are ending with a letter. But a string like
"Kasparov, G."
cannot match.
(Kasparov*)
This can match, among others, the strings "Kasparov"
, and
"Kasparova"
, but it cannot match "Kasparov, Gary"
,
or "Kasparova, Tatiana"
. A parenthetical expression is
excluding the match of blanks and separating characters.
(Kasparov)*
This can match, among others, the strings "Kasparov"
, and
"Kasparov, Gary"
, but it cannot match "Kasparova"
,
or "Kasparova, Tatiana"
.
Kasparov*,*
This can match, among others, the strings "Kasparov, Gary"
, and
"Kasparova, Tatiana"
, but it cannot match "Kasparov"
,
or "Kasparova"
.
Kasparov, Gary
"Kasparov, Gary"
. Because of the
special rule with separating characters also the following strings will
match: "Kasparov,Gary"
(lacking blank character), and
"Kasparov, Gary"
(one blank too many).
Kasparov,\ Gary
This is only matching the string "Kasparov, Gary"
(exactly one
blank character).
!MacDonald
This is matching "MacDonald"
, but not "Macdonald"
,
because the match is case-sensitive.
*\(Berlin\)
This can match the string "Germany (Berlin)"
, among others.
The characters (
, and )
do not have any special
meaning, because they are protected by a backslash. This means that the
string "Germany Berlin"
cannot match.