Instead of the `gsub` here, you'd be better using `Regexp.escape` (http://apidock.com/ruby/v1_9_3_392/Regexp/escape/class)