You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: string.rb
    path of file: ./repos/truffleruby/lib/gems/gems/rake-13.0.6/lib/rake/ext
    
    the code of the file until where you have to start completion: # frozen_string_literal: true
require "rake/ext/core"

class String

  rake_extension("ext") do
    # Replace the file extension with +newext+.  If there is no extension on
    # the string, append the new extension to the end.  If the new extension
    # is not given, or is the empty string, remove any existing extension.
    #
    # +ext+ is a user added 
    
    def pathmap_replace(patterns, &block)
      result = self
      patterns.split(";").each do |pair|
        pattern, replacement = pair.split(",")
        pattern = Regexp.new(pattern)
        if replacement == "*" && block_given?
          result = result.sub(pattern, &block)
        elsif replacement
          result = result.sub(pattern, replacement)
        else
          result = result.sub(pattern, "")
        end
      end