> >function escape( s ) return ( s:gsub( '%p', '%%%1' ) ) end > > I'm a bit puzzled why this one works. `%1` is supposed to refer to the > first capture, but there is no capture in your pattern ... "if the pattern specifies no captures, then it behaves as if the whole pattern was inside a capture." http://www.lua.org/manual/5.2/manual.html#pdf-string.gsub