Announcement (2017-05-07): www.ruby-forum.com is now read-only since I
unfortunately do not have the time to support and maintain the forum any
more. Please see rubyonrails.org/community and ruby-lang.org/en/community
for other Rails- und Ruby-related community platforms.

Peter Bailey wrote:
> Hi,> I'm baffled by this problem. If I define a single file, I can use gsub> to create the same name, with different extensions. But, when I do it> with a list of files, it doesn't work. Why is the code below giving me> nothing but .tif files, when, I'm asking for three different file types:> tif, png, and pdf?>> Thanks,> Peter
"TIF" and "tif" is not the same. You probably want the //i switch which
makes regexen case insensitive. Also I suggest you anchor your regexp,
else you might have unwanted results. E.g. gsub(/\.tif\z/i, ...)
Regards
Stefan

Stefan Rusterholz wrote:
> Peter Bailey wrote:>> Hi,>> I'm baffled by this problem. If I define a single file, I can use gsub>> to create the same name, with different extensions. But, when I do it>> with a list of files, it doesn't work. Why is the code below giving me>> nothing but .tif files, when, I'm asking for three different file types:>> tif, png, and pdf?>>>> Thanks,>> Peter>> "TIF" and "tif" is not the same. You probably want the //i switch which> makes regexen case insensitive. Also I suggest you anchor your regexp,> else you might have unwanted results. E.g. gsub(/\.tif\z/i, ...)>> Regards> Stefan
Thanks, Stefan. You're right. I've been a Windows guy so long that I
overlook the case stuff sometimes. Thanks a lot!

2007/7/19, Peter Bailey <pbailey@bna.com>:
> >> Peter> >> > "TIF" and "tif" is not the same. You probably want the //i switch which> > makes regexen case insensitive. Also I suggest you anchor your regexp,> > else you might have unwanted results. E.g. gsub(/\.tif\z/i, ...)> >> > Regards> > Stefan>> Thanks, Stefan. You're right. I've been a Windows guy so long that I> overlook the case stuff sometimes. Thanks a lot!
Some other remarks: in your case sub is sufficient and you should
probably anchor the expression at the end - just to cover cases where
the sequence occurs somewhere in between.
Kind regards
robert