[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: A Lua 5.2 string pattern issue
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 23 Feb 2010 13:10:22 +0200
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')
end
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.