Jump to content

Wildcard character

From Wikipedia, the free encyclopedia

This is an old revision of this page, as edited by Sandrarossi (talk | contribs) at 08:24, 13 May 2012 (Databases: Undone: "In SAP the plus-sign (+) matches exactly one character." Because SAP is not a database; here + refers to wildcard in ABAP language for search in string of characters, which can be done in memory or converted into SQL it can b). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The term wildcard character has the following meanings:

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 "?" may be substituted for any one of the 36 characters, "A" through "Z" and "0" through "9."
  • Whether the wildcard character represents a single character or a string of characters must be specified.

Computing

In computer (software) technology, a wildcard character can be used to substitute for any other character or characters in a string.

Files and directories

When specifying file names (or paths) in CP/M, DOS, Microsoft Windows and Unix-like operating systems, the asterisk character ("*") substitutes for any zero or more characters, and the question mark ("?") substitutes for any one character or less but not more than the amount of question marks. For example 123??? will match 1231 or 12313 but not 1239919991. In Unix shells and Windows PowerShell, ranges of characters enclosed in square brackets ("[" and "]") substitute for all the characters in their ranges; for example, [A-Za-z] substitutes for any single capitalized or lowercase letter. Unix shells allow negation of the specified characters within brackets by using a leading "!". Matching wildcard patterns to multiple files or paths is referred to as glob expansion.

Databases

In SQL, wildcard characters can be used in "LIKE" expressions; the percent sign (%) matches zero or more characters, and underscore (_) a single character. Transact-SQL also supports square brackets ("[" and "]") to list sets and ranges of characters to match, a leading ^ matches only a character not specified within the brackets. In Microsoft Access, wildcard characters can be used in "LIKE" expressions; the asterisk sign (*) matches zero or more characters, and question mark (?) a single character.

Regular expressions

In regular expressions, the period (.) is the wildcard character for a single character. Combined with the asterisk operator (.*) it will match any number of characters.

Efficiency

When matching against a large string, or against a large number of strings as with database searches, searching with a leading wildcard (*ABC) is considerably more intensive than a trailing wildcard (ABC*). This is because a match against "ABC*" can immediately eliminate all results that don't start with "A" then can proceed to eliminate all results whose second character is not "B" and so on while a match against "*ABC" has to search every character of each potential match at least until it has found "ABC". Leading wildcards especially should be avoided in high performance situations when possible or placed after some other filter to limit the size of the data being searched.

See also

References

  • Public Domain This article incorporates public domain material from Federal Standard 1037C. General Services Administration. Archived from the original on 2022-01-22. (in support of MIL-STD-188).