 <p>The expression <code>[[]]</code> actually consists of two concatenated subexpressions: <code>[[]</code> and <code>]</code>.</p> <ul> <li><code>[[]</code> is character class that matches only <code>[</code> characters. Having <code>[</code> is only possible at the very beginning of a character class.</li> <li><code>]</code> is just a normal character if outside of a character class.</li> </ul> <p>Both are concatenated thus your expression matches any character of <code>[</code> followed by <code>]</code>, which results in matching <code>[]</code>.</p>