If it is possible in your use-case I would not add the replacement character as a paramater and then use the standard ruby string formatting mechanism to format the string. This gives you much better control of the variables that you want replaced within the string.
def x(string, values, rep='%s')
if rep != '%s'
string.gsub!(rep, '%s')
end
string % values
end
a = %w[hello do 12]
puts x("? world what ? you say ?", a, '?')
puts x("%s world what %s you say %3.2f", a)
puts x("%s world what %s you say %3.2f", a, '%s')
And the output from this is as follows
hello world what do you say 12
hello world what do you say 12.00
hello world what do you say 12.00
You will need to be careful with this as too few arguments will cause exceptions so you may wish to trap exceptions and behave appropriately. Without knowing your use-case it's hard to tell if this is appropriate or not.