Domanda

I'm trying to find the hexadecimal non-printable character 00h within a string with Lua. I tried it with an escape character and as a result I get the same location I start in (that's a printable character). I fiddled around with the character classes, but that didn't amount to anything. My approach looks like this:

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

I also tried it this way, but no luck:

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

How can I find this non-printable pattern in Lua?

È stato utile?

Soluzione

It works fine for me:

> 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
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top