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