libfnmatch.tex 1.58 KB
Newer Older
1
\section{Standard Module \module{fnmatch}}
2 3 4 5
\declaremodule{standard}{fnmatch}

\modulesynopsis{\UNIX{} shell style pathname pattern matching.}

6

Fred Drake's avatar
Fred Drake committed
7 8
This module provides support for \UNIX{} shell-style wildcards, which
are \emph{not} the same as regular expressions (which are documented
9
in the \module{re}\refstmodindex{re} module).  The special characters
Fred Drake's avatar
Fred Drake committed
10
used in shell-style wildcards are:
11 12

\begin{list}{}{\leftmargin 0.5in \labelwidth 0.45in}
13 14 15 16
\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}
17
\end{list}
18

Fred Drake's avatar
Fred Drake committed
19 20
Note that the filename separator (\code{'/'} on \UNIX{}) is \emph{not}
special to this module.  See module \code{glob}\refstmodindex{glob}
21
for pathname expansion (\module{glob} uses \function{fnmatch()} to
Fred Drake's avatar
Fred Drake committed
22
match filename segments).
23

24

Fred Drake's avatar
Fred Drake committed
25
\begin{funcdesc}{fnmatch}{filename, pattern}
26 27 28 29 30
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
31 32
standard for your operating system, use \function{fnmatchcase()}
instead.
33 34
\end{funcdesc}

Fred Drake's avatar
Fred Drake committed
35
\begin{funcdesc}{fnmatchcase}{filename, pattern}
36 37 38 39
Test whether \var{filename} matches \var{pattern}, returning true or
false; the comparision is case-sensitive.
\end{funcdesc}

Fred Drake's avatar
Fred Drake committed
40 41 42
\begin{seealso}
\seemodule{glob}{Shell-style path expansion}
\end{seealso}