The syntax for regular expressions is pretty similar to Perl:
s = "I like apple pie" if s =~ /like (.*) pie/ fruit = $1 # == "apple" end
However, substitution is done by calling methods in the String class:
s.sub!("apple", "cherry") s.gsub!("e", "E") s.gsub!(/[aeiou]/){|s| s.upcase}