如何删除字符串中的第一个字符? [Lua]

How do I delete the first character on a string? [Lua]

基本上,我在 Lua 中有一个字符串,这是一个用户输出,但我想要 trim 第一个字符,因为我并不真正需要它。我该怎么做?

您不能删除字符串的第一个字符。

但是您可以使用 string.sub

复制从第二个字符开始的子字符串

string.sub(s, i [,j])

Returns the substring of s that starts at i and continues until j; i and j can be negative. If j is absent, then it is assumed to be equal to -1 (which is the same as the string length)....

因此 str = str:sub(2) 将为您提供 str 的子字符串,该子字符串以字符 2 开头,这就是您想要的。