[docs] Bug in documentation
Julien Palard
julien at palard.fr
Tue Dec 25 17:11:32 EST 2018
Hi Ovidiu,
> In the following page:
>
> https://docs.python.org/3.5/howto/regex.html#matching-characters
>
> The following 2 paragraphs are contradictory:
>
> Metacharacters are not active inside classes. For example,[akm$] will match any of the characters 'a', 'k', 'm', or '$'; '$' is usually a metacharacter, but inside a character class it’s stripped of its special nature.
>
> You can match the characters not listed within the class by complementing the set. This is indicated by including a '^' as the first character of the class; '^' outside a character class will simply match the '^'character. For example, [^5] will match any character except '5'.
Thanks for reporting. I don't think the `^` in classes is a metacharacter, I see it more like a syntax. Anyway to enhance this, we could add a warning in the first paragraph telling that '^' is a kind of an exception. But I don't think it would help a lot, as the second paragraph is here to do the job.
So I don't really see how we can enhance the situation. I'm more conserned by the
> '^' outside a character class will simply match the '^' character.
which seems plain wrong, so I opened an issue about it: https://bugs.python.org/issue35584
Bests,
--
Julien Palard
https://mdk.fr
More information about the docs
mailing list