Skip to content

Instantly share code, notes, and snippets.

@mozamimy
Last active August 29, 2015 14:14
Show Gist options
  • Save mozamimy/1ccb6269705b34e7966a to your computer and use it in GitHub Desktop.
Save mozamimy/1ccb6269705b34e7966a to your computer and use it in GitHub Desktop.
2014-03-05.rb
str = "Alice" # => "Alice"
name = "Alice"
str = "I am #{name}!\n" # => I am Alice!\n
name = "Alice"
str = 'I am #{name}!\n' # => I'm #{name}!\\n
alice = %!Alice! # => "Alice"
cheshire_cat = %Q[Cheshire Cat] # => "Cheshire Cat"
white_rabbit = %q[White Rabbit] # => "White Rabbit"
queen_of_hearts = %Q*Queen of Hearts* # => "Queen of Hearts"
"Alice found a bottle".gsub(/^(.+) found/, '\1 picked up')
# => "Alice picked up a bottle"
"Alice found a bottle".gsub(/^(.+) found/, "\\1 picked up")
# => "Alice picked up a bottle"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment