Ruby-on-rails – How to make this regex rule case insensitive

regexrubyruby-on-railsruby-on-rails-3

I'm doing the following:

email = 'bob@luv.southwest.com'

domain_rules = [/craigslist.org/, /evite.com/, /ziprealty.com/, /alleyinsider.com/, /fedexkinkos.com/, /luv.southwest.com/, /fastsigns.com/, /experts-exchange.com/, /feedburner.com/]

user, domain = email.split('@')

domain_rules.each { |rule| return true if !domain.match(rule).nil? }

Problem is this is case sensitive. Is there a way to make this all case insensative, without having to add /i to the end of every single rule?

Best Solution

Use the option "i" (ignore case)

domain_rules = [
  /craigslist.org/i,
  /evite.com/i,
  /ziprealty.com/i,
  /alleyinsider.com/i,
  /fedexkinkos.com/i,
  /luv.southwest.com/i,
  /fastsigns.com/i,
  /experts-exchange.com/i,
  /feedburner.com/i
]

test it here... http://rubular.com/