3 Awesome Ways To Use Ruby's Gsub Method - RubyGuides
Ruby’s gsub method can do a lot more than simple substitution. Let’s see a few examples. Replace Patterns With A Regular Expression Replacing a single word is fine. But what if you could replace a pattern? Like: A year, an email address, a phone number, etc. You can! Here’s an example: "a1".gsub (/\d/, "2") # "a2"