Inconsistency between `replace` on an `AbstractString` vs. `Vector{Char}`


#1
replace("foobar", "o" => "O", "b" => "B")

gives a method error, but

String(replace(Vector{Char}("foobar"), 'o' => 'O', 'b' => 'B'))

returns “fOOBar”.

That means you can’t optimize the replace operation, so that all characters or strings being replaced can be checked once, instead of doing multiple replacement passes on the string, with all the overhead that entails.


#2

So basically another method needs to be implemented? Everybody is quite busy with breaking changes right now, this kind of feature can be added in 1.x releases.


#3

I said nothing about it’s priority - I was just noting it, as something that hopefully will be addressed at some point, having just gotten bitten by it when I had to convert some code with the deprecated replace(string, txt, rep) to replace(string, txt => rep).


#4

Actually, @klacru has just made a PR to implement this, we just need to find somebody who has skills and time to review it: https://github.com/JuliaLang/julia/pull/25396


#5

I would if I could.