[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: Sean Conner <sean@...>
- Date: Tue, 21 May 2013 13:13:39 -0400
It was thus said that the Great Philipp Janda once stated:
> 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 `-`) ...
>
> Philipp
>
>
> p.s.: Maybe we should have a string.escape() function in Lua's standard
> library (or at least an example in the ref manual ready for copy &
> paste) ...
Or build up an LPeg expression: http://boston.conman.org/2013/01/14.1
-spc