配列に対して複数の正規表現の置換を行いたいのですが、この動作するコードがありますが、それはルビーウェイではないようです、より良い解決策を持っている人はいますか?
#files contains the string that need cleaning
files = [
"Beatles - The Word ",
"The Beatles - The Word",
"Beatles - Tell Me Why",
"Beatles - Tell Me Why (remastered)",
"Beatles - Love me do"
]
#ignore contains the reg expr that need to bee checked
ignore = [/the/,/\(.*\)/,/remastered/,/live/,/remix/,/mix/,/acoustic/,/version/,/ +/]
files.each do |file|
ignore.each do |e|
file.downcase!
file.gsub!(e," ")
file.strip!
end
end
p files
#=>["beatles - word", "beatles - word", "beatles - tell me why", "beatles - tell me why", "beatles - love me do"]