Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 1 | \section{Standard Module \sectcode{fnmatch}} |
Guido van Rossum | e47da0a | 1997-07-17 16:34:52 +0000 | [diff] [blame] | 2 | \label{module-fnmatch} |
Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 3 | \stmodindex{fnmatch} |
| 4 | |
| 5 | This module provides support for Unix shell-style wildcards, which are |
| 6 | \emph{not} the same as Python's regular expressions (which are |
| 7 | documented in the \code{regex} module). The special characters used |
| 8 | in shell-style wildcards are: |
| 9 | \begin{itemize} |
| 10 | \item[\code{*}] matches everything |
| 11 | \item[\code{?}] matches any single character |
| 12 | \item[\code{[}\var{seq}\code{]}] matches any character in \var{seq} |
| 13 | \item[\code{[!}\var{seq}\code{]}] matches any character not in \var{seq} |
| 14 | \end{itemize} |
| 15 | |
| 16 | Note that the filename separator (\code{'/'} on Unix) is \emph{not} |
| 17 | special to this module. See module \code{glob} for pathname expansion |
| 18 | (\code{glob} uses \code{fnmatch} to match filename segments). |
| 19 | |
| 20 | \begin{funcdesc}{fnmatch}{filename\, pattern} |
| 21 | Test whether the \var{filename} string matches the \var{pattern} |
| 22 | string, returning true or false. If the operating system is |
| 23 | case-insensitive, then both parameters will be normalized to all |
| 24 | lower- or upper-case before the comparision is performed. If you |
| 25 | require a case-sensitive comparision regardless of whether that's |
| 26 | standard for your operating system, use \code{fnmatchcase()} instead. |
| 27 | \end{funcdesc} |
| 28 | |
| 29 | \begin{funcdesc}{fnmatchcase}{} |
| 30 | Test whether \var{filename} matches \var{pattern}, returning true or |
| 31 | false; the comparision is case-sensitive. |
| 32 | \end{funcdesc} |
| 33 | |
| 34 | \begin{funcdesc}{translate}{pattern} |
| 35 | Translate a shell pattern into a corresponding regular expression, |
| 36 | returning a string describing the pattern. It does not compile the |
| 37 | expression. |
| 38 | \end{funcdesc} |
| 39 | |