How to replace the charactors in the string?

Quite smart solution. :+1:

but it costs 0.335752 seconds for 100000 loops. In contrast, Perl costs only 0.015 seconds.