Fix replace method to replace all occurrences

I have used the JavaScript string method replace in a wrong way. It only
replaced the first occurrence of the character I wanted to replace. I
have fixed that by using now a regular expression instead.

Signed-off-by: Konrad Reiche <konrad.reiche@gmail.com>