lua-users home
lua-l archive

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


> (And yes always putting in the escaping '%' works fine and is probably
> safer/simpler than a bunch of special cases if you're generating the set…)

You can safely escape any non-alphanumeric character. Escaping
some alphanumeric characters changes their meanings.

    > string.gsub("abc", "[a]", print);
    a
    > string.gsub("abc", "[%a]", print);
    a
    b
    c

The following line should do the trick:

  s = string.gsub(s, "%W", "%%%0")

-- Roberto