blob: 78d0318ec672965004f29812b533e7f147700513 [file] [log] [blame]
Fred Drake295da241998-08-10 19:42:37 +00001\section{\module{fnmatch} ---
2 \UNIX{} shell style pathname pattern matching.}
Fred Drakeb91e9341998-07-23 17:59:49 +00003\declaremodule{standard}{fnmatch}
4
5\modulesynopsis{\UNIX{} shell style pathname pattern matching.}
6
Guido van Rossume76b7a81997-04-27 21:25:52 +00007
Fred Drake48022db1998-01-11 19:06:37 +00008This module provides support for \UNIX{} shell-style wildcards, which
9are \emph{not} the same as regular expressions (which are documented
Fred Drake009ab921998-02-16 21:37:58 +000010in the \module{re}\refstmodindex{re} module). The special characters
Fred Drake48022db1998-01-11 19:06:37 +000011used in shell-style wildcards are:
Fred Drake009ab921998-02-16 21:37:58 +000012
13\begin{list}{}{\leftmargin 0.5in \labelwidth 0.45in}
Guido van Rossume76b7a81997-04-27 21:25:52 +000014\item[\code{*}] matches everything
15\item[\code{?}] matches any single character
16\item[\code{[}\var{seq}\code{]}] matches any character in \var{seq}
17\item[\code{[!}\var{seq}\code{]}] matches any character not in \var{seq}
Fred Drake009ab921998-02-16 21:37:58 +000018\end{list}
Guido van Rossume76b7a81997-04-27 21:25:52 +000019
Fred Drake48022db1998-01-11 19:06:37 +000020Note that the filename separator (\code{'/'} on \UNIX{}) is \emph{not}
21special to this module. See module \code{glob}\refstmodindex{glob}
Fred Drake009ab921998-02-16 21:37:58 +000022for pathname expansion (\module{glob} uses \function{fnmatch()} to
Fred Drake48022db1998-01-11 19:06:37 +000023match filename segments).
Guido van Rossume76b7a81997-04-27 21:25:52 +000024
Fred Drake798654f1997-11-30 05:53:22 +000025
Fred Drake48022db1998-01-11 19:06:37 +000026\begin{funcdesc}{fnmatch}{filename, pattern}
Guido van Rossume76b7a81997-04-27 21:25:52 +000027Test whether the \var{filename} string matches the \var{pattern}
28string, returning true or false. If the operating system is
29case-insensitive, then both parameters will be normalized to all
30lower- or upper-case before the comparision is performed. If you
31require a case-sensitive comparision regardless of whether that's
Fred Drake009ab921998-02-16 21:37:58 +000032standard for your operating system, use \function{fnmatchcase()}
33instead.
Guido van Rossume76b7a81997-04-27 21:25:52 +000034\end{funcdesc}
35
Fred Drake48022db1998-01-11 19:06:37 +000036\begin{funcdesc}{fnmatchcase}{filename, pattern}
Guido van Rossume76b7a81997-04-27 21:25:52 +000037Test whether \var{filename} matches \var{pattern}, returning true or
38false; the comparision is case-sensitive.
39\end{funcdesc}
40
Fred Drake48022db1998-01-11 19:06:37 +000041\begin{seealso}
Fred Drake48022db1998-01-11 19:06:37 +000042\seemodule{glob}{Shell-style path expansion}
43\end{seealso}