lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


It was thus said that the Great Roberto Ierusalimschy once stated:
> > But!  There is this:
> > 
> > 	%x: (where x is any non-alphanumeric character) represents the
> > 	character x.  This is the standard way to escape the magic
> > 	characters. Any non-alphanumeric character (including all
> > 	punctuations, even the non-magical) can be preceded by a '%' when
> > 	used to represent itself in a pattern.
> > 
> > So to me, that says that '%%' is NOT a class and can therefore be used as
> > mentioned.  I wonder what Roberto meant by the example of "[a-%%]".  Perhaps
> > a typo?
> 
> Where does it say it is not a class? Read the whole story:
> 
>   |  The following combinations are allowed in describing a character class:
>   |
>   |    %x: (where x is any non-alphanumeric character) represents the [...]
> 
> It is a class: a unit set, which includes only that character.

  Okay, but what were you trying to get across with "[a-%%]"?  That
reverse ranges don't work? [1]

  I think I was confused because 
	
	("a"):match "[%%-a]"

worked, but in playing with it further, it seems that this created a class
of three characters, '%', '-' and 'a'.  Wierd.

  -spc (Which is why I tend to use LPeg---these type of issues just go away ... )

[1]	"[z-a]" will fail, for instance.