Over a million developers have joined DZone.

Escape Single Quotes In Ruby Strings

·

class String
  def escape_single_quotes
    self.gsub(/[']/, '\\\\\'')
  end
end


Useful if you ever get the idea of shoving Ruby strings into JavaScript code.
Topics:

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}