lua-users home
lua-l archive

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


On May 21, 2013, at 1:24 PM, Philipp Janda <siffiejoe@gmx.net> wrote:

> which is probably not what you wanted. So you need to put a few more escapes in there (at least before `%`, `.`, and `-`) …

Quoting the manual… "Any punctuation character (even the non magic) can be preceded by a '%' when used to represent itself in a pattern."… so… perhaps this can all be simplified to just gsub( '%p', '%%%0' ) )…

For example:

print( ( '1234-5;:/<>.%' ):gsub( '%p', '%%%0' ) )

> 1234%-5%;%:%/%<%>%.%%	8

http://www.lua.org/manual/5.2/manual.html#6.4.1