Wish Ruby had a String#each_sub method that returned each string with each matching substring replaced, individually

# => ["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 but that's not the same.

Sign in to participate in the conversation

A Mastodon instance for Rubyists & friends