ID EN
Pathlib

match

Python 3.11

Match this path against the provided glob-style pattern. Return True if matching is successful, False otherwise.

Syntax

PYTHON
PurePath.match(pattern)

Examples

Example 1
PYTHON
>>> PurePath('a/b.py').match('*.py')
True
>>> PurePath('/a/b/c.py').match('b/*.py')
True
>>> PurePath('/a/b/c.py').match('a/*.py')
False
Example 2
PYTHON
>>> PurePath('/a.py').match('/*.py')
True
>>> PurePath('a/b.py').match('/*.py')
False
Example 3
PYTHON
>>> PurePosixPath('b.py').match('*.PY')
False
>>> PureWindowsPath('b.py').match('*.PY')
True