Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{fnmatch} --- |
| 2 | \UNIX{} shell style pathname pattern matching.} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 3 | \declaremodule{standard}{fnmatch} |
| 4 | |
| 5 | \modulesynopsis{\UNIX{} shell style pathname pattern matching.} |
| 6 | |
Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 7 | |
Fred Drake | 48022db | 1998-01-11 19:06:37 +0000 | [diff] [blame] | 8 | This module provides support for \UNIX{} shell-style wildcards, which |
| 9 | are \emph{not} the same as regular expressions (which are documented |
Fred Drake | 009ab92 | 1998-02-16 21:37:58 +0000 | [diff] [blame] | 10 | in the \module{re}\refstmodindex{re} module). The special characters |
Fred Drake | 48022db | 1998-01-11 19:06:37 +0000 | [diff] [blame] | 11 | used in shell-style wildcards are: |
Fred Drake | 009ab92 | 1998-02-16 21:37:58 +0000 | [diff] [blame] | 12 | |
| 13 | \begin{list}{}{\leftmargin 0.5in \labelwidth 0.45in} |
Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 14 | \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 Drake | 009ab92 | 1998-02-16 21:37:58 +0000 | [diff] [blame] | 18 | \end{list} |
Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 19 | |
Fred Drake | 48022db | 1998-01-11 19:06:37 +0000 | [diff] [blame] | 20 | Note that the filename separator (\code{'/'} on \UNIX{}) is \emph{not} |
| 21 | special to this module. See module \code{glob}\refstmodindex{glob} |
Fred Drake | 009ab92 | 1998-02-16 21:37:58 +0000 | [diff] [blame] | 22 | for pathname expansion (\module{glob} uses \function{fnmatch()} to |
Fred Drake | 48022db | 1998-01-11 19:06:37 +0000 | [diff] [blame] | 23 | match filename segments). |
Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 24 | |
Fred Drake | 798654f | 1997-11-30 05:53:22 +0000 | [diff] [blame] | 25 | |
Fred Drake | 48022db | 1998-01-11 19:06:37 +0000 | [diff] [blame] | 26 | \begin{funcdesc}{fnmatch}{filename, pattern} |
Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 27 | Test whether the \var{filename} string matches the \var{pattern} |
| 28 | string, returning true or false. If the operating system is |
| 29 | case-insensitive, then both parameters will be normalized to all |
| 30 | lower- or upper-case before the comparision is performed. If you |
| 31 | require a case-sensitive comparision regardless of whether that's |
Fred Drake | 009ab92 | 1998-02-16 21:37:58 +0000 | [diff] [blame] | 32 | standard for your operating system, use \function{fnmatchcase()} |
| 33 | instead. |
Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 34 | \end{funcdesc} |
| 35 | |
Fred Drake | 48022db | 1998-01-11 19:06:37 +0000 | [diff] [blame] | 36 | \begin{funcdesc}{fnmatchcase}{filename, pattern} |
Guido van Rossum | e76b7a8 | 1997-04-27 21:25:52 +0000 | [diff] [blame] | 37 | Test whether \var{filename} matches \var{pattern}, returning true or |
| 38 | false; the comparision is case-sensitive. |
| 39 | \end{funcdesc} |
| 40 | |
Fred Drake | 48022db | 1998-01-11 19:06:37 +0000 | [diff] [blame] | 41 | \begin{seealso} |
Fred Drake | 48022db | 1998-01-11 19:06:37 +0000 | [diff] [blame] | 42 | \seemodule{glob}{Shell-style path expansion} |
| 43 | \end{seealso} |