I'm referring to ECMAScript regular expression syntax defined in https://tc39.es/ecma262/#sec-regexp-regular-expression-objects.
I checked how the following pattern matches in a regular expression via several online sources.
Pattern: /[[]]/
They all included that
[ -> Match any character in the character set
[ -> Matches a `[` character
]
] -> Matches a `]` character
I get how the character set is matched, but I don't understand why the last closing bracket(]) is matched. Isn't it a syntax error in the regular expression since a PatternCharacter can only be a SourceCharacter that is not a SyntaxCharacter according to the syntax defined ECMAScript specification (https://tc39.es/ecma262/#prod-PatternCharacter)? The closing bracket(]) is a SyntaxCharacter.
PatternCharacter ::
SourceCharacter but not SyntaxCharacter