Mega Code Archive

 
Categories / Ruby / Hash
 

Output hash to string then remove the key and gsub

myHash = { 1920 => "value for 1920", 1925 => "value for 1925", 1934 => "value for 1934" } novels = myHash.to_s # => "1925value for 19251920value for 19201934value for 1934" novels.gsub(/\d{4}/, " " ) { |token| print token } # => " value for 1925 value for 1920 value for 1934"