[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Patterns: Why are anchors not character classes?
- From: Sean Conner <sean@...>
- Date: Sun, 19 Jul 2015 16:01:31 -0400
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.
- References:
- Re: Patterns: Why are anchors not character classes?, John Hind
- Re: Patterns: Why are anchors not character classes?, Dirk Laurie
- Re: Patterns: Why are anchors not character classes?, Rena
- Re: Patterns: Why are anchors not character classes?, Tom N Harris
- Re: Patterns: Why are anchors not character classes?, Rena
- Re: Patterns: Why are anchors not character classes?, Soni L.
- Re: Patterns: Why are anchors not character classes?, Sean Conner
- Re: Patterns: Why are anchors not character classes?, Soni L.
- Re: Patterns: Why are anchors not character classes?, Sean Conner
- Re: Patterns: Why are anchors not character classes?, Roberto Ierusalimschy