Moin!

Andreas Schwarz wrote:

> Exactly. The only solutions I can think of:
> 1) use regex_escape() for the string that should be replaced, and
>    remove backreferences in the replacement string manually
> 2) do it char by char, like in C.

3) class String
      def simple_global_replace(find, replace)
        self.split(/(#{Regexp.quote(find)})/).map { |elm|
          elm == find ? replace : elm
        }.join("")
      end
    end

    "hello.world.bar".simple_global_replace(".", "...")
    # => "hello...world...bar"


> 1) is ugly, 2) is slow and even uglier.

3) is slow and maybe even ugly.

Regards,
flgr