Ruby match first occurrence of string for a gsub replacement August 30, 2023 by Tarik Use sub, not gsub. gsub is global, sub isn’t.