blob: 86c907373b3d4ea9c75c1f5ad1ee4431e7998231 [file] [log] [blame]
Guido van Rossume76b7a81997-04-27 21:25:52 +00001\section{Standard Module \sectcode{fnmatch}}
Guido van Rossume47da0a1997-07-17 16:34:52 +00002\label{module-fnmatch}
Guido van Rossume76b7a81997-04-27 21:25:52 +00003\stmodindex{fnmatch}
4
5This module provides support for Unix shell-style wildcards, which are
6\emph{not} the same as Python's regular expressions (which are
7documented in the \code{regex} module). The special characters used
8in 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
16Note that the filename separator (\code{'/'} on Unix) is \emph{not}
17special 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}
21Test whether the \var{filename} string matches the \var{pattern}
22string, returning true or false. If the operating system is
23case-insensitive, then both parameters will be normalized to all
24lower- or upper-case before the comparision is performed. If you
25require a case-sensitive comparision regardless of whether that's
26standard for your operating system, use \code{fnmatchcase()} instead.
27\end{funcdesc}
28
29\begin{funcdesc}{fnmatchcase}{}
30Test whether \var{filename} matches \var{pattern}, returning true or
31false; the comparision is case-sensitive.
32\end{funcdesc}
33
34\begin{funcdesc}{translate}{pattern}
35Translate a shell pattern into a corresponding regular expression,
36returning a string describing the pattern. It does not compile the
37expression.
38\end{funcdesc}
39