Topic: Problem with array

I have an array like this:
array = [ "manyThings.mp3", "myLike.gif", "moreCoco.bmp",
"theFormat.bmp"]

and I want to make some comparison to eliminate all the words in the
array that are NOT of the bmp format.  So at the end the array will look
like this:

array = ["moreCoco.bmp", "theFormat.bmp"]

is there a way to do this???

Many thanks for the help

Re: Problem with array

array.select { |a| a =~ /\.bmp$/ }

Or make it more readable using the Rails ends_with? method:

array.select { |a| a.ends_with?('.bmp') }

Rob Anderton
TheWebFellas

Re: Problem with array

I'm fairly new to Ruby but I have to say things like the Array select and map are real time savers.

http://www.benjaminbooth.com/tableorboo … s_sel.html