[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Problem with table key iteration when string keys are unpredictable
- From: "S. Fisher" <expandafter@...>
- Date: Tue, 21 May 2013 07:44:18 -0700 (PDT)
--- On Tue, 5/21/13, Philipp Janda <siffiejoe@gmx.net> wrote:
> Am 21.05.2013 12:48 schröbte S.
> Fisher:
> >
> > function escape( s )
> > return string.gsub(s, "[][^$()%.*+-?]",
> "%%%0" )
> > end
> >
>
> Try:
>
> > =escape( "12345;:/<>%" )
> %1%2%3%4%5%;%:%/%<%>%
> 10
>
> which is probably not what you wanted. So you need to put a
> few more escapes in there (at least before `%`, `.`, and
> `-`) ...
function escape( s )
return string.gsub(s, "[][^$()%%.*+?-]", "%%%0" )
end
> =escape( "1234-5;:/<>.%" )
1234%-5;:/<>%.%% 3