On Fri, 24 Nov 2006, Peter Bailey wrote: > Hi, > Can someone point me to a quick "grep" like function in RUBY? I use glob Not the answer you want [below], but look at glark http://www.incava.org/projects/glark/ It is a ruby grep, "interbred" with find... > all the time, but, I need the power of regular expressions when finding > particular files in directories. I see "grep" in the Pickaxe manual, > but, only as it relates to ".enum," which, sorry to say, I don't > understand. Dir["*"].grep(/^c/) # all entries matching * (glob) that begin with C. enum is enumerable -- `ri Enumerable` gives: <quote> ------------------------------------------------------ Class: Enumerable The +Enumerable+ mixin provides collection classes with several traversal and searching methods, and with the ability to sort. The class must provide a method +each+, which yields successive members of the collection. If +Enumerable#max+, +#min+, or +#sort+ is used, the objects in the collection must also implement a meaningful +<=>+ operator, as these methods rely on an ordering between members of the collection. ------------------------------------------------------------------------ Instance methods: ----------------- all?, any?, collect, detect, each_cons, each_slice, each_with_index, entries, enum_cons, enum_slice, enum_with_index, find, find_all, grep, include?, inject, inject, map, max, member?, min, partition, reject, select, sort, sort_by, to_a, to_set, zip </quote> And of course Dir.[] gives something with an each method. > > I need something like this, even though, I know this doesn't work: > Dir.glob(/^f[0-9]{7}\.eps/) > > Thanks! > Peter HTH Hugh