# tmuxp.cli.search.find_search_matches

- **Module:** tmuxp.cli.search
- **Package:** tmuxp
- **Language:** Python
- **Kind:** function
- **Source:** https://github.com/tmux-python/tmuxp/blob/153acdf6ff1268b14d3d03ed488f545a7123c8f1/src/tmuxp/cli/search.py#L779
- **Page:** https://libtmux.org/en/py/latest/workspace/reference/tmuxp-cli-search-find_search_matches/

```
tmuxp.cli.search.find_search_matches(workspaces: list[tuple[pathlib.Path, str]], patterns: list[SearchPattern], match_any: bool = False, invert_match: bool = False) -> list[WorkspaceSearchResult]
```

Find workspaces matching search patterns.

## Parameters

- `workspaces` (list[tuple[pathlib.Path, str]]): List of (filepath, source) tuples to search. Source is "local" or "global".
- `patterns` (list[SearchPattern]): Compiled search patterns.
- `match_any` (bool): If True, match if ANY pattern matches (OR logic). Default False (AND).
- `invert_match` (bool): If True, return workspaces that do NOT match. Default False.

## Returns

list[WorkspaceSearchResult]
    List of matching workspace results with match information.

## Example

```python
>>> import tempfile
>>> import pathlib
>>> import re
>>> content = "session_name: dev-session" + chr(10) + "windows: []"
>>> with tempfile.NamedTemporaryFile(
...     suffix='.yaml', delete=False, mode='w'
... ) as f:
...     _ = f.write(content)
...     temp_path = pathlib.Path(f.name)
```

## Example

```python
>>> pattern = SearchPattern(
...     fields=("session_name",),
...     raw="dev",
...     regex=re.compile("dev"),
... )
>>> results = find_search_matches([(temp_path, "global")], [pattern])
>>> len(results)
1
>>> results[0]["source"]
'global'
```

## Example

Invert match returns non-matching workspaces:

```python
>>> pattern_nomatch = SearchPattern(
...     fields=("name",),
...     raw="nonexistent",
...     regex=re.compile("nonexistent"),
... )
>>> results = find_search_matches(
...     [(temp_path, "global")], [pattern_nomatch], invert_match=True
... )
>>> len(results)
1
>>> temp_path.unlink()
```
