# tmuxp.cli.search.highlight_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#L864
- **Page:** https://libtmux.org/en/py/latest/workspace/reference/tmuxp-cli-search-highlight_matches/

```
tmuxp.cli.search.highlight_matches(text: str, patterns: list[SearchPattern], colors: Colors) -> str
```

Highlight regex matches in text.

## Parameters

- `text` (str): Text to search and highlight.
- `patterns` (list[SearchPattern]): Compiled search patterns (uses their regex attribute).
- `colors` (Colors): Color manager for highlighting.

## Returns

str
    Text with matches highlighted, or original text if no matches.

## Example

```python
>>> from tmuxp.cli._colors import ColorMode, Colors
>>> colors = Colors(ColorMode.NEVER)
>>> pattern = SearchPattern(
...     fields=("name",),
...     raw="dev",
...     regex=re.compile("dev"),
... )
>>> highlight_matches("development", [pattern], colors=colors)
'development'
```

## Example

With colors enabled (ALWAYS mode):

```python
>>> colors_on = Colors(ColorMode.ALWAYS)
>>> result = highlight_matches("development", [pattern], colors=colors_on)
>>> "dev" in result
True
>>> chr(27) in result  # Contains ANSI escape
True
```
