I want to do
["""] = "QuotedDouble"
" is being used as a string in between “” like “string”
1 Like
Use \
to break out of special characters.
1 Like
Do you backslash a backslash for "\"
?
I think the correct way to do it is: "\""
To include a regular backlash without ignoring a character: \\
Another way you could do it is using ‘ ״quoted text” ‘
Also, using [[text]]
creates a string literal, ignoring any special characters contained within.
local str1 = "\n\n\n' \"\\"
print(str1)
--> newline newline newline' "\
local str2 = [[\n\n\n' \"\\]]
print(str2)
--> \n\n\n' "\"\\
If you need to use double brackets in your string, you can go even further:
local str = [==[ [[ double brackets as part of the string ]] ]==]
And lastly, you can use string literals to make multiline strings.
local str = [[line 1
line 2
line 3]]
3 Likes
local Strings = {"\"", '"', [["]], string.char(34), utf8.char(34)}
for _, String in ipairs(Strings) do
print(String)
end
I know of 5 ways to produce the string.