Alternatively referred to as a wild character or wildcard character, a wildcard is a symbol used to replace or represent one or more characters. Wildcards are typically either an asterisk (*), which represents one or more characters or question mark (?), which represents a single character. In the examples below of how a wildcard may be used, realize that wildcards are relatively universal.
Percent ( % ) in a wildcard
Asterisk ( * ) in a wildcard
The asterisk in a wildcard matches any character zero or more times. For example, "comp*" matches anything beginning with "comp" which means "comp", "complete", and "computer" are all matched.
Question mark ( ? ) in a wildcard
A question mark matches a single character once. For example, "c?mp" matches "camp" and "comp". The question mark can also be used more than once. For example, "c??p" would match both of the above examples as well as "coop." In MS-DOS and the Windows command line the question mark also can match any trailing question marks zero or one times. For example, "co??" would match all of the above matches, but because they are trailing question marks would also match "cop" even though its not four characters.
Tip: With regular expressions a period ( . ) is a wildcard for a single character.
Open and close brackets ( [ ] ) in a wildcard
With Unix shells, Windows PowerShell, and programming languages that support regular expressions the open and close bracket wildcards match a single character in a range. For example, [a-z] matches any character "a" through "z", which means anything not in that range like a number would not be matched.
Tip: Adding an exclamation in places that support the brackets as a wildcard will tell the program to NOT match.
MS-DOS and Windows command line wildcard examples
List files in MS-DOS using the dir command that contain c, mp, and any other character in-between. For example, comp, camp, c2mp, and c-mp would all be matched.
List any file that ends with data using the dir command. For example, the files 'appdata', 'mydata', and '123data' would all be matched.
List any file that is four characters long, begins with he, and has any extension. For example, help.txt, help.mp3, and heck.jpg would all be matched.
rename *.txt *.jpg
Rename all files in the current directory that end with the file extension .txt to .jpg. For example, the file test.txt would become test.jpg.
Deleting files in MS-DOS that begin with comp and end with a .txt extension.
Find and Replace using wildcard examples
Find and Replace features that support wildcards like Microsoft Word allow searches to contain wildcards. Below are examples of how to use wildcards in Find and Replace. Keep in mind that for any of these to work you must have the Use wildcards option checked in Find and Replace.
Match anything starting with 'comp' and ending with 'r'. In other words, this would find "computer" and "compiler" in your document. However, keep in mind that "*" is greedy which means everything is matched up to 'r'. In other words, if there is an 'r' after comp it would be matched, so "computer your" would be matched since it begins with 'comp' and your ends with 'r'.
Using brackets indicate to Microsoft Word to look for any of the letters contained in the brackets. In this example, 'e' or 'o' are matched, so find would match either "dell" or "doll."
The brackets can also be used to search for a range of characters. In the above example, this range is all of the letters from 'o' to 'u' which would match words like "dell", "doll", and "dull" in your document.
Using an exclamation in the brackets tells the Find to no match any of the characters in the bracket. In the above example, this wildcard tells the Find to not match "dell", but match anything else beginning with 'd' and ending in 'll.
The question mark only matches one character. In the above example, this would match the words "dall", "dell", "dill", "doll", and "dull" since they contain a 'd' at the first and 'll' at the end.
Using a curly bracket in your Find looks for the amount of characters preceding the brackets. In the above example, Find matches "seed", but not match "sed".
A find starting with a less than and containing text in parentheses tells Find to look for any word beginning with whatever is contained within the parentheses. In the above example, this would find any words beginning with "comp".
A string starting with characters in a parenthesis and ending a greater than tells Find to look for any word ending with whatever is contained within the parentheses. In the above example, this would find any words ending with "er".
Linux and Unix wildcard examples
Listing files using the ls command in a Linux variant or Unix variant that begin with comp.
Deleting files using the rm command in a Linux or Unix variant that contain c, mp, and any character in-between.
Microsoft Excel wildcard examples