match_pattern
functionsignature
match_pattern(pattern, path): boolMatch a dot-separated `path` against a glob `pattern`. Rules over dot-separated segments: - a literal segment matches itself exactly, - `*` matches exactly one segment, - `**` matches zero or more segments. Uses an iterative segment glob with backtracking — no per-suffix recursion or string re-joining (the standard wildcard algorithm where `*` ≈ `?` and `**` ≈ `*`). A leading dot on either argument is ignored.
Parameters
| Name | Type | Description |
|---|---|---|
pattern | str | The pattern, possibly containing `*`/`**`. |
| Name | Type | Description |
|---|---|---|
path | str | The subject path to test. |
Returns
bool — `True` if the pattern matches the path.
Example
example
>>> match_pattern("a.*", "a.b")
True
>>> match_pattern("a.*", "a.b.c")
False
>>> match_pattern("a.**", "a")
True
>>> match_pattern("**.end", "x.y.end")
True