1997-04-27 21:25:52 +00:00
|
|
|
\section{Standard Module \sectcode{fnmatch}}
|
1997-07-17 16:34:52 +00:00
|
|
|
\label{module-fnmatch}
|
1997-04-27 21:25:52 +00:00
|
|
|
\stmodindex{fnmatch}
|
|
|
|
|
|
|
|
This module provides support for Unix shell-style wildcards, which are
|
1997-12-30 04:43:36 +00:00
|
|
|
\emph{not} the same as regular expressions (which are
|
1997-12-15 17:53:31 +00:00
|
|
|
documented in the \code{re} module). The special characters used
|
1997-04-27 21:25:52 +00:00
|
|
|
in shell-style wildcards are:
|
|
|
|
\begin{itemize}
|
|
|
|
\item[\code{*}] matches everything
|
|
|
|
\item[\code{?}] matches any single character
|
|
|
|
\item[\code{[}\var{seq}\code{]}] matches any character in \var{seq}
|
|
|
|
\item[\code{[!}\var{seq}\code{]}] matches any character not in \var{seq}
|
|
|
|
\end{itemize}
|
|
|
|
|
|
|
|
Note that the filename separator (\code{'/'} on Unix) is \emph{not}
|
|
|
|
special to this module. See module \code{glob} for pathname expansion
|
|
|
|
(\code{glob} uses \code{fnmatch} to match filename segments).
|
|
|
|
|
1997-11-30 05:53:22 +00:00
|
|
|
\renewcommand{\indexsubitem}{(in module fnmatch)}
|
|
|
|
|
1997-04-27 21:25:52 +00:00
|
|
|
\begin{funcdesc}{fnmatch}{filename\, pattern}
|
|
|
|
Test whether the \var{filename} string matches the \var{pattern}
|
|
|
|
string, returning true or false. If the operating system is
|
|
|
|
case-insensitive, then both parameters will be normalized to all
|
|
|
|
lower- or upper-case before the comparision is performed. If you
|
|
|
|
require a case-sensitive comparision regardless of whether that's
|
|
|
|
standard for your operating system, use \code{fnmatchcase()} instead.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{fnmatchcase}{}
|
|
|
|
Test whether \var{filename} matches \var{pattern}, returning true or
|
|
|
|
false; the comparision is case-sensitive.
|
|
|
|
\end{funcdesc}
|
|
|
|
|
|
|
|
\begin{funcdesc}{translate}{pattern}
|
|
|
|
Translate a shell pattern into a corresponding regular expression,
|
|
|
|
returning a string describing the pattern. It does not compile the
|
1997-12-30 04:43:36 +00:00
|
|
|
expression. \strong{Version note:} in Python 1.4 and earlier, this
|
|
|
|
function translated to \code{regex} (Emacs style) regular expressions;
|
|
|
|
in 1.5 and later, it translates to \code{re} (Perl style) regular
|
|
|
|
expressions.
|
1997-04-27 21:25:52 +00:00
|
|
|
\end{funcdesc}
|
|
|
|
|