Underscore in regex pattern for a leaf

I’m afraid I have to disagree - that text is not such a definition, it is only a restriction on when the ^ character is valid at the beginning of a positive character group. It doesn’t say anything about whether it is valid elsewhere in a positive character group, and nothing about whether it is valid in a negative character group.

But if you read the preceding definitions, the ^ character is clearly part of the “XmlChar” definition, and thus follows the rule

A single XML character is a character range that identifies the set of characters containing only itself.

I.e. it should only need to be escaped when you want to use it as the first character of a positive character group (that isn’t part of a negative character group:-).