Ruby: Strings

In Ruby, a String is created with double-quotes:

"I am a String"

String interpolation is done in Ruby with # { }:

new_string = "New"
"I am a #{new_string}"

Return the lowercase version of a String:

"I am a String".downcase

Replace any substring of String that matches “\r” with a space:

"I\ram\ra\rString".gsub("\r", " ") 

Replace any substring of String that matches a Regular Expression with a space:

"fallacy".gsub(/[^a]/, " ") # Regular expression