Skip to content

Instantly share code, notes, and snippets.

/a.rb Secret

Created April 12, 2016 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/fa5a05d4f41991f40422223e2c53b6d2 to your computer and use it in GitHub Desktop.
Save anonymous/fa5a05d4f41991f40422223e2c53b6d2 to your computer and use it in GitHub Desktop.
a = 'aly\'s dog'
=> "aly's dog"
a.sub '\'', '#'
=> "aly#s dog"
a.sub '\'', 'test'
=> "alytests dog"
a.sub '\'', '\\'
=> "aly\\s dog"
a.sub '\'', '\\\''
=> "alys dogs dog"
# should be "aly\'s dog"
a.sub "'", "\'"
=> "aly's dog"
1.9.3-p0 :051 > a.sub "'", "\\'"
=> "alys dogs dog"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment