Changing regex to use \A and \z as suggested by Rails 4.0.0beta1