class Cucumber::StepMatch

def replace_arguments(string, step_arguments, format)

def replace_arguments(string, step_arguments, format)
  s = string.dup
  offset = past_offset = 0
  step_arguments.each do |step_argument|
    group = step_argument.group
    next if group.value.nil? || group.start < past_offset
    replacement = if block_given?
                    yield(group.value)
                  elsif format.instance_of?(Proc)
                    format.call(group.value)
                  else
                    format % group.value
                  end
    s[group.start + offset, group.value.length] = replacement
    offset += replacement.unpack('U*').length - group.value.unpack('U*').length
    past_offset = group.start + group.value.length
  end
  s
end