mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			43 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			TeX
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
	
		
			1.6 KiB
		
	
	
	
		
			TeX
		
	
	
	
	
	
\section{\module{fnmatch} ---
 | 
						|
         \UNIX{} shell style pathname pattern matching.}
 | 
						|
\declaremodule{standard}{fnmatch}
 | 
						|
 | 
						|
\modulesynopsis{\UNIX{} shell style pathname pattern matching.}
 | 
						|
 | 
						|
 | 
						|
This module provides support for \UNIX{} shell-style wildcards, which
 | 
						|
are \emph{not} the same as regular expressions (which are documented
 | 
						|
in the \module{re}\refstmodindex{re} module).  The special characters
 | 
						|
used in shell-style wildcards are:
 | 
						|
 | 
						|
\begin{list}{}{\leftmargin 0.5in \labelwidth 0.45in}
 | 
						|
\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}
 | 
						|
\end{list}
 | 
						|
 | 
						|
Note that the filename separator (\code{'/'} on \UNIX{}) is \emph{not}
 | 
						|
special to this module.  See module \code{glob}\refstmodindex{glob}
 | 
						|
for pathname expansion (\module{glob} uses \function{fnmatch()} to
 | 
						|
match filename segments).
 | 
						|
 | 
						|
 | 
						|
\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 comparision is performed.  If you
 | 
						|
require a case-sensitive comparision 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 comparision is case-sensitive.
 | 
						|
\end{funcdesc}
 | 
						|
 | 
						|
\begin{seealso}
 | 
						|
\seemodule{glob}{Shell-style path expansion}
 | 
						|
\end{seealso}
 |