TiL: Doing multiple replacements with gsub in Ruby

gsub is great. It lets you replace characters in a string. All you have to do is give it a regex that will match whatever it is you want to replace and the string that you’d like to replace each match with. For example, if you wanted to replace the time of 18:00 with something a bit more human-readable, you could do the following: 'As always, tea time is at 18:00....

July 30, 2024 · 2 min · 245 words · George Bell