lua-users home
lua-l archive

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


On 19 January 2012 10:01, Sean Conner <sean@conman.org> wrote:
 An easy way to do that is

       res = res:gsub("%&","&amp;")


& doesn't need to be escaped in lua patterns; and in fact: shouldn't.

res = res:gsub("&","&amp;")

will do

As a note; other special entities need to be escaped too:

res = res:gsub("[<>&\"]",{ ["<"] = "&lt;" , [">"]="&gt;" , ["&"]="&amp;" , ["\""] = "&quot;" } )

D