[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Character class with negated "]"
From: |
Hans-Bernhard Broeker |
Subject: |
Re: Character class with negated "]" |
Date: |
Mon, 9 Sep 2002 14:09:01 +0200 (MET DST) |
On Mon, 9 Sep 2002, Hans Aberg wrote:
> How do I indicated a character class with a negated "]"?
>
> I want to negate: * [ ]
> The problems is then that attempts like
> [^*[]]+
> will not work, as the "]" will be interpreted as the character class
> closing bracket.
For special cases like this, I seem to remember special
position-sensitivity built into most RE parsers. Have you tried
[^][*]+
At least with egrep, this does indeed work --- I haven't tested flex.
The idea is that ] will work if it's the first thing inside the [] pair,
where it cannot possibly mean the end of the class. The '^' operator is
transparent for this, i.e. [ is still considered the first in this class.
--
Hans-Bernhard Broeker (address@hidden)
Even if all the snow were burnt, ashes would remain.