Skip to content

Default word regex and snake_case checking #2979

@DimitriPapadopoulos

Description

@DimitriPapadopoulos

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\\-'’`]+"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions