Replacing \ by \\ in a String

Dear haxians,

i must replace every \ in a string by \ and i have no idea how to do this. I feel very stupid.
Please help me! :slight_smile:

thanks!

using StringTools;
string.replace("\\", "\\\\");

Hi Gama. Thanks for the fast reply.
That’s exactly what I was trying. But it didn’t work.

description = description.replace( '\\', '\\\\');

I’m using Haxe 4 RC3 and targeting JS

It works here : Try Haxe ! and I don’t see differences on higher Haxe versions in JavaScript target.

i found my mistake.There are some ‘\n’ and ‘\t’ in the string. I have to replace them seperately with ‘\n’ and ‘\t’

Thanks for help! :slight_smile: