Replacing ^ and $ multiline anchors with \A and \z to avoid a security risk and support Rails 4.