lua-users home
lua-l archive

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

I've come across a new error when doing some compatibility tests with
Lua 5.2 (work2, naturally!)

-- escape.lua
-- escape all magic characters except $, which has special meaning
-- Also, un-escape any characters after $, so $( passes through as is.
function escape (spec)
    return spec:gsub('[%-%.%+%[%]%(%)%^%%%?%*]','%%%1'):gsub('%$%%(%S)','%$%1')
print(escape '$({def} $')

$ lua escape.lua
$({def} $       1
$ lua52 escape.lua
lua52: escape.lua:2: invalid use of '%' in replacement string

Clearly something has changed; am I doing anything odd?

steve d.