Ruby/File Directory/fnmatch
Материал из Wiki.crossplatform.ru
File name matching with flags
flags = File::FNM_PATHNAME | File::FNM_DOTMATCH File.fnmatch("lib/*.rb", "lib/a.rb", flags) # => true File.fnmatch("lib/*.rb", "lib/a/b.rb", flags) # => false File.fnmatch("lib/**/*.rb", "lib/a.rb", flags) # => true File.fnmatch("lib/**/*.rb", "lib/a/b.rb", flags) # => true
Find patter matching
File.fnmatch("*.rb", "hello.rb") # => true File.fnmatch("*.[ch]", "ruby.c") # => true File.fnmatch("*.[ch]", "ruby.h") # => true File.fnmatch("?.txt", "ab.txt") # => false