[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [^\]] in basic regexes
From: |
Wacek Kusnierczyk |
Subject: |
Re: [^\]] in basic regexes |
Date: |
Sat, 14 Feb 2009 13:50:13 +0100 |
User-agent: |
Thunderbird 2.0.0.19 (X11/20090105) |
Andreas Schwab wrote:
> Wacek Kusnierczyk <address@hidden> writes:
>
>
>> however, in that code the pattern was '[^\]]*' (with the idea that the
>> character ']' is a metacharacter and therefore must be escaped).
>>
>
> Inside bracket expressions the backslash is not special. Thus '[^\]]'
> is a pattern that matches a non-backslash character followed by ']', and
> '[\]' does not qualify.
>
well, the pattern either is 'one character which is neither a backslash
nor a closing bracket' (thus, the leftmost and rightmost brackets
denote a class), then the pattern should match the opening bracket in
the data.
if, as you seem to imply, the pattern is 'a non-backslash followed by a
closing bracket', then
- the rightmost closing bracket is *outside* of any class (the class
[^\] has been closed), thus
- it is (should be) a *metacharacter*, and and as such
- it must be taken as *closing a class*, which is not there and it
neither should match the closing bracket in the data (which it does in
some of the other examples)