On Thu, Feb 14, 2013 at 4:59 PM, Sloan Ruby <[email protected]> wrote:
> I have been googling and am not sure how to approach this. I have a > file that I need to match. The date string in the filename varies so I > want to match any date. > > /path/to/file/hist_sar01-31-2013.tar > > What options do i have for matching the/any date or string. Is there a > method for matching? > > hist_sar*.tar > if Dir["/path/to/file/hist_sar*.tar"].empty? # code to run if no files matching pattern exist else # code to run otherwise end You could also make the pattern more specific: http://www.ruby-doc.org/core-1.9.3/Dir.html#method-c-glob Example: Dir["/path/to/file/hist_sar{0,1}[0-9]-[0-3][0-9]-[0-9][0-9][0-9][0-9].tar"] > > -- > Posted via http://www.ruby-forum.com/. > > -- Kendall Gifford [email protected] -- [email protected] | https://groups.google.com/d/forum/ruby-talk-google?hl=en --- You received this message because you are subscribed to the Google Groups "ruby-talk-google" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/groups/opt_out.
