blob: 8bce50a18e98ebf863509af9f82f6a85fc8bd922 [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
Fred Drake798654f1997-11-30 05:53:22 +000020\renewcommand{\indexsubitem}{(in module fnmatch)}
21
Guido van Rossume76b7a81997-04-27 21:25:52 +000022\begin{funcdesc}{fnmatch}{filename\, pattern}
23Test whether the \var{filename} string matches the \var{pattern}
24string, returning true or false. If the operating system is
25case-insensitive, then both parameters will be normalized to all
26lower- or upper-case before the comparision is performed. If you
27require a case-sensitive comparision regardless of whether that's
28standard for your operating system, use \code{fnmatchcase()} instead.
29\end{funcdesc}
30
31\begin{funcdesc}{fnmatchcase}{}
32Test whether \var{filename} matches \var{pattern}, returning true or
33false; the comparision is case-sensitive.
34\end{funcdesc}
35
36\begin{funcdesc}{translate}{pattern}
37Translate a shell pattern into a corresponding regular expression,
38returning a string describing the pattern. It does not compile the
39expression.
40\end{funcdesc}
41