[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Feature request: plain option for gsub
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Thu, 21 Aug 2014 22:05:57 -0300
> >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