From: ahoward Date: 2003-05-13T06:06:07+09:00 Subject: Re: shell glob match On Tue, 13 May 2003, Dave Thomas wrote: > Try fnmatch (in 1.8) so i should stop work on my fnmatch extension then? ;-) guess this is not in the shim - bummer - i'll have to wait. -a > > dave[StarterKit/SCC 14:49:48] ri fnmatch > This is a test 'ri'. Please report errors and omissions > on http://www.rubygarden.org/ruby?RIOnePointEight > > ---------------------------------------------------------- File::fnmatch > File.fnmatch( aPattern, aPath, [flags] ) -> (true or false) > ------------------------------------------------------------------------ > Returns true if aPath matches against aPattern The pattern is not a > regular expression; instead it follows rules similar to shell > filename globbing. It may contain the following metacharacters: > flags is a bitwise OR of the FNM_xxx parameters listed in on page > unknown. The same glob pattern and flags are used by Dir::glob. > File.fnmatch('cat', 'cat') #=> true > File.fnmatch('cat', 'category') #=> false > File.fnmatch('c{at,ub}s', 'cats') #=> false > File.fnmatch('c{at,ub}s', 'cubs') #=> false > File.fnmatch('c{at,ub}s', 'cat') #=> false > File.fnmatch('c?t', 'cat') #=> true > File.fnmatch('c\?t', 'cat') #=> false > File.fnmatch('c??t', 'cat') #=> false > File.fnmatch('c*', 'cats') #=> true > File.fnmatch('c/**/t', 'c/a/b/c/t') #=> true > File.fnmatch('c*t', 'cat') #=> true > File.fnmatch('c\at', 'cat') #=> true > File.fnmatch('c\at', 'cat', File::FNM_NOESCAPE) #=> false > File.fnmatch('a?b', 'a/b') #=> true > File.fnmatch('a?b', 'a/b', File::FNM_PATHNAME) #=> false > File.fnmatch('*', '.profile') #=> false > File.fnmatch('*', '.profile', File::FNM_DOTMATCH) #=> true > File.fnmatch('*', 'dave/.profile') #=> true > File.fnmatch('*', 'dave/.profile', File::FNM_DOTMATCH) #=> true > File.fnmatch('*', 'dave/.profile', File::FNM_PATHNAME) #=> > false > File.fnmatch('*/*', 'dave/.profile', File::FNM_PATHNAME) #=> > false > STRICT = File::FNM_PATHNAME | File::FNM_DOTMATCH > File.fnmatch('*/*', 'dave/.profile', STRICT) #=> true > > > > -- ==================================== | Ara Howard | NOAA Forecast Systems Laboratory | Information and Technology Services | Data Systems Group | R/FST 325 Broadway | Boulder, CO 80305-3328 | Email: ara.t.howard@fsl.noaa.gov | Phone: 303-497-7238 | Fax: 303-497-7259 ====================================