Wish Ruby had a String#each_sub method that returned each string with each matching substring replaced, individually
"A1A2A3".each_sub('A','X')# => ["X1A2A3", "A1X2A3", "A1A2X3"]
Or String#all_indexes(substring) or String#all_matches(regexp) methods to find all occurrences of a substring or regexp.
@postmodern That *would* nice. Especially if it took a block, too. I mean there is #gsub but that's not the same.
A Mastodon instance for Rubyists & friends