Use of a regex stored inside a YAML file I installed settingslogic and in the configuration file I put the regex for the email as follows:

#config/settings.yml
defaults: &amp;defaults

  email_regex: /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i

development:
  &lt;&lt;: *defaults
  # neat_setting: 800

test:
  &lt;&lt;: *defaults

production:
  &lt;&lt;: *defaults


That I load in devise configuration in this way:

#config/initializers/devise.rb
  # Regex to use to validate the email address
  # config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
  config.email_regexp = eval Settings.email_regex


It works, but what do you think about that eval? Is it the correct way to convert a string to a regex?
If you want to use a regexp in a yaml file you need to use !ruby/regexp

#config/settings.yml
defaults: &amp;defaults

  email_regex: !ruby/regexp '/^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i'


Edit:
 The solution proposed by Mike Bethany is very similar to the yaml implementation.

You can take a look to what is used in Ruby 1.9.2 here (search for "!ruby/regexp"):
https://github.com/tenderlove/psych/blob/master/lib/psych/visitors/to_ruby.rb

PS (and OT): I think, like Mike Bethany, that this basic functionality belong to the Regexp class not yaml, and need to be moved to a Regexp method. What do you think?