[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: What's wrong with my string.gsub()?
- From: Alexander Gladysh <agladysh@...>
- Date: Mon, 3 Jan 2011 07:50:08 +0300
On Mon, Jan 3, 2011 at 04:40, KHMan <keinhong@gmail.com> wrote:
> On 1/3/2011 9:21 AM, Steve Litt wrote:
> string.gsub() wants a pattern for the second operand. But you want to use v
> as a literal. So you need to escape those "%" (and perhaps other magic
> characters) and make gsub interpret v as a literal.
> "%a%Aarg please=>%%" => "%%a%%Aarg please=>%%%%" (I think)
This function may be useful:
https://github.com/lua-nucleo/lua-nucleo/blob/master/lua-nucleo/string.lua#L137-158
(I think that may actually be a reuse of some code on Lua-Users.)
Alexander.