3

我正在尝试使用 Lua 在字符串中查找十六进制不可打印字符 00h。我用转义字符尝试了它,结果我得到了我开始的相同位置(那是一个可打印的字符)。我摆弄了角色类,但这并没有什么意义。我的方法如下所示:

location = string.find(variable,"\00",startlocation)

我也尝试过这种方式,但没有运气:

location = string.find(variable, string.char(00),startlocation)

如何在 Lua 中找到这种不可打印的模式?

4

1 回答 1

2

这对我来说可以:

> return string.find("one\0two\0,three","\0,")
8   9
> return string.find("one\0two\0,three","\0")
4   4
> return string.find("one\0two\0,three","\00")
4   4
> return string.find("one\0two\0,three","\00",6)
8   8
于 2012-01-27T10:56:28.697 回答