Andreas Schwab wrote: > Wacek Kusnierczyk <[email protected]> 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)
