Wildcard character

From English Wikipedia @ Freddythechick

In software, a wildcard character is a kind of placeholder represented by a single character, such as an asterisk (<syntaxhighlight lang="text" class="" style="" inline="1">*</syntaxhighlight>), which can be interpreted as a number of literal characters or an empty string. It is often used in file searches so the full name need not be typed.[1]

Telecommunication

In telecommunications, a wildcard is a character that may be substituted for any of a defined subset of all possible characters.

  • In high-frequency (HF) radio automatic link establishment, the wildcard character <syntaxhighlight lang="text" class="" style="" inline="1">?</syntaxhighlight> may be substituted for any one of the 36 upper-case alphanumeric characters.
  • Whether the wildcard character represents a single character or a string of characters must be specified.

Computing

In computer (software) technology, a wildcard is a symbol used to replace or represent zero or more characters.[2] Algorithms for matching wildcards have been developed in a number of recursive and non-recursive varieties.[3]

File and directory patterns

When specifying file names (or paths) in CP/M, DOS, Microsoft Windows, and Unix-like operating systems, the asterisk character (<syntaxhighlight lang="text" class="" style="" inline="1">*</syntaxhighlight>, also called "star") matches zero or more characters. For example, <syntaxhighlight lang="text" class="" style="" inline="1">doc*</syntaxhighlight> matches <syntaxhighlight lang="text" class="" style="" inline="1">doc</syntaxhighlight> and <syntaxhighlight lang="text" class="" style="" inline="1">document</syntaxhighlight> but not <syntaxhighlight lang="text" class="" style="" inline="1">dodo</syntaxhighlight>. If files are named with a date stamp, wildcards can be used to match date ranges, such as 202505*.mp4 to select video recordings from May 2025, to facilitate file operations such as copying and moving.

In Unix-like and DOS operating systems, the question mark <syntaxhighlight lang="text" class="" style="" inline="1">?</syntaxhighlight> matches exactly one character. In DOS, if the question mark is placed at the end of the word, it will also match missing (zero) trailing characters; for example, the pattern <syntaxhighlight lang="text" class="" style="" inline="1">123?</syntaxhighlight> will match <syntaxhighlight lang="text" class="" style="" inline="1">123</syntaxhighlight> and <syntaxhighlight lang="text" class="" style="" inline="1">1234</syntaxhighlight>, but not <syntaxhighlight lang="text" class="" style="" inline="1">12345</syntaxhighlight>.

In Unix shells and Windows PowerShell, ranges of characters enclosed in square brackets (<syntaxhighlight lang="text" class="" style="" inline="1">[</syntaxhighlight> and <syntaxhighlight lang="text" class="" style="" inline="1">]</syntaxhighlight>) match a single character within the set; for example, <syntaxhighlight lang="text" class="" style="" inline="1">[A-Za-z]</syntaxhighlight> matches any single uppercase or lowercase letter. In Unix shells, a leading exclamation mark <syntaxhighlight lang="text" class="" style="" inline="1">!</syntaxhighlight> negates the set and matches only a character not within the list. In shells that interpret <syntaxhighlight lang="text" class="" style="" inline="1">!</syntaxhighlight> as a history substitution, a leading caret <syntaxhighlight lang="text" class="" style="" inline="1">^</syntaxhighlight> can be used instead.

The operation of matching of wildcard patterns to multiple file or path names is referred to as globbing.

Databases

In SQL, wildcard characters can be used in LIKE expressions; the percent sign <syntaxhighlight lang="text" class="" style="" inline="1">%</syntaxhighlight> matches zero or more characters, and underscore <syntaxhighlight lang="text" class="" style="" inline="1">_</syntaxhighlight> a single character. Transact-SQL also supports square brackets (<syntaxhighlight lang="text" class="" style="" inline="1">[</syntaxhighlight> and <syntaxhighlight lang="text" class="" style="" inline="1">]</syntaxhighlight>) to list sets and ranges of characters to match, a leading caret <syntaxhighlight lang="text" class="" style="" inline="1">^</syntaxhighlight> negates the set and matches only a character not within the list. In Microsoft Access, the asterisk sign <syntaxhighlight lang="text" class="" style="" inline="1">*</syntaxhighlight> matches zero or more characters, the question mark <syntaxhighlight lang="text" class="" style="" inline="1">?</syntaxhighlight> matches a single character, the number sign <syntaxhighlight lang="text" class="" style="" inline="1">#</syntaxhighlight> matches a single digit (0–9), and square brackets can be used for sets or ranges of characters to match.

Regular expressions

In regular expressions, the period (<syntaxhighlight lang="text" class="" style="" inline="1">.</syntaxhighlight>, also called "dot") is the wildcard pattern which matches any single character. Combined with the asterisk operator <syntaxhighlight lang="text" class="" style="" inline="1">.*</syntaxhighlight> it will match any number of any characters.

In this case, the asterisk is also known as the Kleene star.

See also

References

  1. ^ "Using wildcard characters". Microsoft. Archived from the original on 2017-03-24. Retrieved 2018-01-23.
  2. ^ "What is a wildcard?". Computer Hope. Archived from the original on 2016-11-21. Retrieved 2016-11-21.
  3. ^ Cantatore, Alessandro (Apr 25, 2003). "Wildcard matching algorithms". Archived from the original on Oct 14, 2023.

External links