Using the? Wildcard

Consider the wildcard pattern ????.COB. The following files will match from the list shown earlier:

        APP.COB                ONE.COB

        PEN.COB                ATTL.COB

Each ? can be replaced by one character or none. Since there are four ?s in the wildcard pattern, all files which have four or less characters in their primary name are listed by DOS.

DOS interprets a question mark in the same way as a card player interprets a joker—as a card that can substitute any other card.

Other characters can be intermingled with wildcard characters. An example is the wildcard pattern A???.COB.

This wildcard pattern will match all file names with primary names beginning with A and having four or less characters and the extension .COB.

From the files listed earlier, the following file names would be matched:

        APP.COB                ATTLCOB

If you have a file named PAINT.BAT and the wildcard pattern you specify is PA??T.BAT, the file PAINT.BAT will be listed.

Let us assume you have a file named SMS.PW and you wish to check if this file exists on the disk by using the wildcard pattern S7MS.PW.

DOS will display a message saying that the file has not been found. This is because ? can be matched by one character or none if it is specified at the end of a file name. However, when ? is specified in the middle of a file name, it has to be matched by exactly one character. The following example will illustrate this better.

Assume you have the following files on your disk:

        SIMPSON.KNG                PASTE.PAM

        TWINK.CS                        TWILIGHT.HZN

        PALE.PAM

The wildcard pattern you specify is P???E.PAM. Here the file PASTE.PAM will be matched and not PALE.PAM, even though their extensions are the same, i.e. PAM, and their primary names begin and end with the same letters. This is because the three ?s in the middle of the wildcard pattern must be matched by exactly three characters, like in PASTE.PAM. Similarly, each ? wildcard that is followed by other characters in a pattern has.to be matched by exactly one character.