Q:

Regex in array or hash - sorting

I have a work folder directory. 
holder = Dir.glob("*")
=> holder = ["Project One", "Project Two", "Project Three", "Backups", "Summer 2012"]

I would like to use regex in my script to sort a new file that is in another directory into one of the Project directories above. I can easily do this using a regex.match command like. 
other_files = ["Project One Picture 2399.jpg", "Project Two Doc.txt"]
if /project\Done/i.match(other_files[0])
#if true cp to Project One directory i think you get the point

I would like to create regex expression from the holder array. So all i need to do is create another folder and the script will add another regex in the array. Is there an easy way to do this? Or is there a way to store regex in an array? 
regex_array = ["/project\Done/i", "/project\Dtwo/i", "/project\Dthree/i", "/backups/i", "/summer\W\d\d\d\d/i"]

A:

Regexp.new creates a new regex:
Regexp.new 'your expression'
# => /your expression/

You can push these onto your regex_array. You can store them as regexes, not strings.
regex_array = holder.map {|folder| Regexp.new(folder.downcase, Regexp::IGNORECASE) }
# => [/project one/i, /project two/i, /project three/i]

