String.gsub("","","")?

Hiya! I’m here with a stupid issue I can’t solve. :slight_smile:

I want to replace any " in a string with \".
This is what I attempted:

local te = string.gsub('Press "start" to begin','"','\"')
print(te)

Although that just returns press "start" to begin… How’d I accomplish this? Thanks in advance for the help! :slight_smile:

Try using two backslashes maybe:

local te = string.gsub('Press "start" to begin','"','\\"')
print(te)
2 Likes

I was going to say that, but golden beat me to it. Good game.

4 Likes

Testing it, one moment… I’ll update this post!

EDIT: Thank you very much!! image

1 Like

The reason for this, by the way, is that \ is an escape character (aka special functionality) and therefore needs to be escaped (made not-special by using the escape character) if you want it to have no functionality, just like how you need to do %% to match %.

2 Likes