blob: 7aa12957c2181b6e0816efb6f305586a3666c07d [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
Fred Drake48022db1998-01-11 19:06:37 +00005This module provides support for \UNIX{} shell-style wildcards, which
6are \emph{not} the same as regular expressions (which are documented
7in the \code{re}\refstmodindex{re} module). The special characters
8used in shell-style wildcards are:
Guido van Rossume76b7a81997-04-27 21:25:52 +00009\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
Fred Drake48022db1998-01-11 19:06:37 +000016Note that the filename separator (\code{'/'} on \UNIX{}) is \emph{not}
17special to this module. See module \code{glob}\refstmodindex{glob}
18for pathname expansion (\code{glob} uses \code{fnmatch()} to
19match filename segments).
Guido van Rossume76b7a81997-04-27 21:25:52 +000020
Fred Drake19479911998-02-13 06:58:54 +000021\setindexsubitem{(in module fnmatch)}
Fred Drake798654f1997-11-30 05:53:22 +000022
Fred Drake48022db1998-01-11 19:06:37 +000023\begin{funcdesc}{fnmatch}{filename, pattern}
Guido van Rossume76b7a81997-04-27 21:25:52 +000024Test whether the \var{filename} string matches the \var{pattern}
25string, returning true or false. If the operating system is
26case-insensitive, then both parameters will be normalized to all
27lower- or upper-case before the comparision is performed. If you
28require a case-sensitive comparision regardless of whether that's
29standard for your operating system, use \code{fnmatchcase()} instead.
30\end{funcdesc}
31
Fred Drake48022db1998-01-11 19:06:37 +000032\begin{funcdesc}{fnmatchcase}{filename, pattern}
Guido van Rossume76b7a81997-04-27 21:25:52 +000033Test whether \var{filename} matches \var{pattern}, returning true or
34false; the comparision is case-sensitive.
35\end{funcdesc}
36
Fred Drake48022db1998-01-11 19:06:37 +000037\begin{seealso}
Guido van Rossume76b7a81997-04-27 21:25:52 +000038
Fred Drake48022db1998-01-11 19:06:37 +000039\seemodule{glob}{Shell-style path expansion}
40\end{seealso}