How do I remove a substring after a certain character in a string using Ruby? August 12, 2023 by Tarik new_str = str.slice(0..(str.index('blah')))