Help with escaping backslashes

Hey there! I am making a program that allows you to run code from anywhere and I am having trouble because the string that I set in my Node.js file looks like this:

'print("Hello, World")'

But when I bring it into Roblox so I can loadstring it, the double-quotes have been escaped, like this:

"print(\"Hello, World\")"

What I am trying to figure out is how to escape those backslashes. I have tried the DevHub, DevForum, Just plain old RegEx (didn’t work because I forgot that roblox does not support RegEx) and everything in between.

You can write strings this way.

print([["Hello, World"]])

…but for escaping the backslashes, do it twice:

print('\\"Hello, World\\"')
1 Like

This did not work as I intended. I tried to add double backslashes in my Node code, and all it did was add ANOTHER backslash, so then I tried to just put one backslash, but since that is the correct escape syntax in JS, it didn’t add another, so I am back at square one.