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