Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Dir.glob and File.fnmatch

Reply
Thread Tools

Dir.glob and File.fnmatch

 
 
Thomas Leitner
Guest
Posts: n/a
 
      05-08-2005
Hi,

I always thought that the arguments to Dir.glob(...) and
File.fnmatch(...) are the same. However, with the first I can use
braces, with File.fnmatch not!

irb(main):001:0> Dir['*']
=> ["src", "plugin"]
irb(main):002:0> Dir.glob('s{rc}')
=> ["src"]
irb(main):003:0> File.fnmatch('s{rc}','src')
=> false

Is it somehow possible to use braces with File.fnmatch(...)?

Thomas

--
|\ Thomas Leitner -- thomas [underscore] leitner [at] gmx [dot] at
|>
|/ "Life is what happens to you while you're busy making other plans"



 
Reply With Quote
 
 
 
 
nobu.nokada@softhome.net
Guest
Posts: n/a
 
      05-09-2005
Hi,

At Sun, 8 May 2005 23:46:18 +0900,
Thomas Leitner wrote in [ruby-talk:141672]:
> I always thought that the arguments to Dir.glob(...) and
> File.fnmatch(...) are the same. However, with the first I can use
> braces, with File.fnmatch not!


Brace Expansion is different from Pathname Expansion.

--
Nobu Nakada


 
Reply With Quote
 
 
 
 
Piergiuliano Bossi
Guest
Posts: n/a
 
      05-10-2005
wrote:
> Hi,
>
> At Sun, 8 May 2005 23:46:18 +0900,
> Thomas Leitner wrote in [ruby-talk:141672]:
>
>>I always thought that the arguments to Dir.glob(...) and
>>File.fnmatch(...) are the same. However, with the first I can use
>>braces, with File.fnmatch not!

>
>
> Brace Expansion is different from Pathname Expansion.
>


Yes, PickaxeII contains a better explanation than ri and effectively
differentiate the semantics between the two: "Because fnmatch is
implemented by the underlying operating system, it may have different
semantics to Dir.glob." ==> ie: braces are not used to delimit patterns
to match.

IMHO ri description needs to be slightly enhanced.

HTH
Giuliano

--
If you want to send me an email address should be 'p', then a dot,
followed by 'bossi' at 'quinary', another dot and 'com' at last
 
Reply With Quote
 
Thomas Leitner
Guest
Posts: n/a
 
      05-11-2005
Thanks for the answers! So I will stick to Dir.glob for the time being.

Thomas

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if and and vs if and,and titi VHDL 4 03-11-2007 05:23 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57