Skip to content

re fails to match ranges starting with escaped - #1978

@slozier

Description

@slozier

re fails to match ranges starting with escaped -. For example:

assert re.match(r'[\--/]', '.') # fails
assert re.match(r'[--/]', '.') # works

This causes a failure in test_fnmatch (from 3.8).

Appears to be a bug in .NET: dotnet/runtime#108335

Idea for a fix: have the re module alter the pattern to be something like [\-.-/] so it matches - and a range starting with . (the next character).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions