# Regex Search

Search pasted text with a regex or literal pattern and return matching lines with line numbers, context, invert, whole-word, and highlighting.

## Run it

- **CLI:** `gizza tool regex-search "Paste the text or log to search…" 'pattern=e.g. ERROR|WARN'`
- **Web:** https://gizza.ai/tools/regex-search/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/regex-search/tool.json

## Inputs

- `text` — Text _(field)_
- `pattern` — Pattern _(field)_
- `literal` — Literal (match the pattern as a fixed string) _(field)_
- `ignore_case` — Ignore case _(field)_
- `whole_word` — Whole word only _(field)_
- `invert` — Invert (show non-matching lines) _(field)_
- `context` — Context lines (before & after) _(field)_
- `line_numbers` — Show line numbers _(field)_
- `highlight` — Highlight matches _(field)_

## Output

- Matching lines (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `text` — Text
- `pattern` — Pattern
- `literal` — Literal (match the pattern as a fixed string)
- `ignore_case` — Ignore case
- `whole_word` — Whole word only
- `invert` — Invert (show non-matching lines)
- `context` — Context lines (before & after)
- `line_numbers` — Show line numbers
- `highlight` — Highlight matches

Example: `https://gizza.ai/tools/regex-search/?text=Paste%20the%20text%20or%20log%20to%20search%E2%80%A6&pattern=e.g.%20ERROR%7CWARN&literal=true&ignore_case=true&whole_word=true&invert=true&context=0&line_numbers=true&highlight=true`

---

## About this tool

Regex Search is a browser-based `grep` for pasted text. Drop in a log, a config
file, or any block of text, type a regular expression (or a plain literal
string), and get back **every whole line that matches** — with 1-based line
numbers, an optional window of surrounding context lines, and match
highlighting. It runs entirely in your browser with pure-Rust WebAssembly:
nothing you paste is uploaded anywhere.

It mirrors the flags you already know from Unix `grep`: ignore case (`-i`),
whole-word only (`-w`), invert to show the lines that *don't* match (`-v`),
fixed-string/literal mode (`-F`), context lines (`-C`), and line numbers (`-n`).

### Worked example

Paste this text:

```
starting up
ERROR disk full
retrying
ERROR timeout
done
```

with the pattern `ERROR` and line numbers on, and you get:

```
2 matching lines:
2:ERROR disk full
4:ERROR timeout
```

Each hit line is prefixed with `line-number:`. Turn on **Context lines** and the
surrounding lines appear with a `line-number-` prefix, and non-adjacent groups
are separated by a `--` line — exactly like `grep -C`.

### Limits & notes

- Matching uses [Rust `regex`](https://docs.rs/regex) syntax. It is fast and
  linear-time, but it does **not** support backreferences or look-around
  assertions (`\1`, `(?=…)`, `(?<=…)`); rewrite those patterns without them.
- Search is line-oriented: `^` and `$` anchor the start and end of each line, so
  a pattern never matches across a line break.
- Highlighting wraps matches in `«` and `»` markers (the output is plain text,
  so it stays copy-paste safe); context lines are never highlighted.
- To pull out the matched *substrings* or a capture group instead of whole
  lines, use the regex-extract tool; to debug a pattern's spans and capture
  groups, use the regex-tester tool.

## FAQ

<details>
<summary>What is the difference between this and a "find in page" search?</summary>

Browser find highlights matches in place; this returns a clean, copy-pasteable
list of just the matching lines, with line numbers and an optional context
window. It also understands full regular expressions, invert, whole-word, and
case-insensitive matching — the way `grep` does on the command line.

</details>

<details>
<summary>Which regex syntax is supported?</summary>

The Rust `regex` crate syntax: character classes (`[a-z]`, `\d`, `\w`, `\s`),
anchors (`^`, `$`, `\b`), quantifiers (`*`, `+`, `?`, `{2,5}`), groups, and
alternation (`ERROR|WARN`). Backreferences and look-around (`\1`, `(?=…)`) are
**not** supported, which is what keeps matching guaranteed linear-time even on
large inputs.

</details>

<details>
<summary>How do I search for a literal string with special characters?</summary>

Turn on **Literal**. In literal mode every regex metacharacter is escaped, so a
pattern like `a.c` matches only the exact text `a.c` and not `abc`. It's the
equivalent of `grep -F`.

</details>

<details>
<summary>Can I show a few lines around each match?</summary>

Yes — set **Context lines** to the number of lines you want before and after
each hit (like `grep -C N`). Context lines are prefixed with `-` instead of `:`,
overlapping windows are merged, and separate groups are divided by a `--` line.

</details>

<details>
<summary>Is my text uploaded to a server?</summary>

No. All matching happens locally in your browser via WebAssembly. The text you
paste never leaves your machine.

</details>

## Related tools

- [Fuzzy Text Search](https://gizza.ai/tools/fuzzy-doc-search/): Paste text and fuzzy-search it — find the best-matching lines even with typos, ranked by relevance with the matches highlighted. Runs in your browser, no upload.
- [Text Pipeline Playground](https://gizza.ai/tools/text-pipeline-playground/): Pipe pasted text through a chain of transforms — grep, reject, regex replace, sort, unique, head/tail, split, join — with a tiny safe DSL. Free, private, in your browser.
- [CSS Autoprefixer](https://gizza.ai/tools/css-autoprefixer/): Free online CSS autoprefixer — paste CSS and add the -webkit-, -moz-, -ms-, -o- vendor prefixes browsers still need. Runs entirely in your browser.
- [Dotenv Manager](https://gizza.ai/tools/dotenv-manager/): Parse, validate, merge and secret-mask .env files in your browser: flag duplicate and missing keys, lint names, and export .env.example or JSON. No upload.
- [Dotenv Validator](https://gizza.ai/tools/dotenv-validator/): Paste a .env file to catch duplicate keys, unquoted spaces, malformed ${VAR} interpolation and undefined references. Runs locally in your browser.
