match_pattern

function
yoltra/loose_event_bus.py:46
signature
match_pattern(pattern, path): bool

Match 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

NameTypeDescription
patternstrThe pattern, possibly containing `*`/`**`.
NameTypeDescription
pathstrThe 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