The underscore (_) is part of \w. From https://docs.python.org/3/library/re.html#regular-expression-syntax:
\w
For Unicode (str) patterns:
Matches Unicode word characters; this includes alphanumeric characters (as defined by str.isalnum()) as well as the underscore (_). If the ASCII flag is used, only [a-zA-Z0-9_] is matched.
For 8-bit (bytes) patterns:
Matches characters considered alphanumeric in the ASCII character set; this is equivalent to [a-zA-Z0-9_]. If the LOCALE flag is used, matches characters considered alphanumeric in the current locale and the underscore.
Is there an easy way to get \w except _ in the non-ASCII case? It would help checking snake_case.
|
word_regex_def = "[\\w\\-'’`]+" |
The underscore (
_) is part of\w. From https://docs.python.org/3/library/re.html#regular-expression-syntax:Is there an easy way to get
\wexcept_in the non-ASCIIcase? It would help checking snake_case.codespell/codespell_lib/_codespell.py
Line 31 in ec0a5b9