summaryrefslogtreecommitdiffstats
path: root/Doc/lib/libfnmatch.tex
blob: 4d184bc858a4b72aa2e27ea1d89d075ca1644fe8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
\section{\module{fnmatch} ---
         \UNIX{} filename pattern matching}

\declaremodule{standard}{fnmatch}
\modulesynopsis{\UNIX\ shell style filename pattern matching.}


\index{filenames!wildcard expansion}

This module provides support for \UNIX{} shell-style wildcards, which
are \emph{not} the same as regular expressions (which are documented
in the \refmodule{re}\refstmodindex{re} module).  The special
characters used in shell-style wildcards are:

\begin{tableii}{c|l}{code}{Pattern}{Meaning}
  \lineii{*}{matches everything}
  \lineii{?}{matches any single character}
  \lineii{[\var{seq}]}{matches any character in \var{seq}}
  \lineii{[!\var{seq}]}{matches any character not in \var{seq}}
\end{tableii}

Note that the filename separator (\code{'/'} on \UNIX{}) is \emph{not}
special to this module.  See module
\refmodule{glob}\refstmodindex{glob} for pathname expansion
(\refmodule{glob} uses \function{fnmatch()} to match pathname
segments).  Similarly, filenames starting with a period are
not special for this module, and are matched by the \code{*} and
\code{?} patterns.


\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 comparison is performed.  If you
require a case-sensitive comparison regardless of whether that's
standard for your operating system, use \function{fnmatchcase()}
instead.
\end{funcdesc}

\begin{funcdesc}{fnmatchcase}{filename, pattern}
Test whether \var{filename} matches \var{pattern}, returning true or
false; the comparison is case-sensitive.
\end{funcdesc}


\begin{seealso}
  \seemodule{glob}{\UNIX{} shell-style path expansion.}
\end{seealso}