Escape a character in a string

Started by Florin Calinescu, Apr 15, 2016, 04:48 PM

Previous topic - Next topic

Florin Calinescu

Tried something like this: stringerino+=\"+anotherstringerino+\";Didn't work.Any suggestions?

.

#1
You are escaping the quotes which mark the beginning and ending of the string. Therefore, the script compiler doesn't know what you meant with that and tries to interpret it as valid code. Therefore, it won't compile.

If you want to use double-quotes inside a string, you escape them but also include the quotes that mark the beginning and ending of the string:
local stringerino1 = "\"+anotherstringerino+\"";
local stringerino2 = "\"+another\"string\"erino+\"";

print(stringerino1); // output (quotes included): "+anotherstringerino+"
print(stringerino2); // output (quotes included): "+another"string"erino+"
.