How do I remove a substring after a certain character in a string using Ruby?
I'm surprised nobody suggested to use 'gsub'
irb> "truncate".gsub(/a.*/, 'a') => "trunca"
The bang version of gsub can be used to modify the string.