lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> While I had no problems with that in the past, I just spotted the pattern of the matching does treat the first \0 as the end of the pattern.

Ah, so that’s why "%z" exists...

I think the following would "pre-process" an arbitrary binary string,
making it ready to be searched for in another arbitrary binary string:

-- searching for s in another string...
s = string.gsub(s, "[%z%p]", function(c)
    if c == "\0" then
        return "%z"
        return "%" .. c