GH-73435: Implement recursive wildcards in `pathlib.PurePath.match()` by barneygale · Pull Request #101398 · python/cpython

@barneygale

…ch()

Add a new *recursive* argument to `pathlib.PurePath.match()`, defaulting
to `False`. If set to true, `match()` handles the `**` wildcard as in
`Path.glob()`, i.e. it matches any number of path segments.

We now compile a `re.Pattern` object for the entire pattern. This is made
more difficult by `fnmatch` not treating directory separators as special
when evaluating wildcards (`*`, `?`, etc), and so we arrange the path parts
onto separate *lines* in a string, and ensure we don't set `re.DOTALL`.

@barneygale

@barneygale

This was referenced

Mar 12, 2023

@barneygale barneygale changed the title gh-73435: Implement recursive wildcards in pathlib.PurePath.match() GH-73435: Implement recursive wildcards in pathlib.PurePath.match()

May 3, 2023

zooba

@barneygale

AlexWaygood

@barneygale @AlexWaygood

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>

This was referenced

Jul 2, 2023