Lua 转义多行字符串

lea*_*eak 1 string lua escaping

你好,我想知道我是否可以在多行字符串中转义 [[ 和 ]]

例子:

s = [[  [[ test ]] ]]
Run Code Online (Sandbox Code Playgroud)

然后如果我这样做

print(test)
Run Code Online (Sandbox Code Playgroud)

我希望输出是, [[ test ]]

有没有办法做到这一点?

Dar*_*yer 5

Lua 多行字符串不仅仅使​​用[[and ]]; 您也可以=在两者之间放置尽可能多的[](但必须是相同的数字):

local str = [=====[
 ]] This does nothing
 ]=] not enough =
 ]==========] too many =
]=====] -- This closes the string
Run Code Online (Sandbox Code Playgroud)