---
title: "Fast regex search: indexing text for agent tools · Cursor"
description: "Agents lean heavily on regex search, and ripgrep's full scan can take over 15 seconds in large monorepos, so Cursor builds local indexes specifically to accelerate regex queries."
url: "https://swe.quest/articles/fast-regex-search-indexing-text-for-agent-tools-cursor-45908cf7bb0688f8"
canonical: "https://cursor.com/blog/fast-regex-search"
source: "Cursor"
published: "2026-03-23"
difficulty: "medium"
kind: "Deep dive"
reading_minutes: 20
tags: ["search","data-structures","algorithms","ai-agents","developer-tools"]
---

# Fast regex search: indexing text for agent tools · Cursor

A post on [Cursor](https://swe.quest/sources/cursor.md), published 2026-03-23, 20 min read, Deep dive. Original: [https://cursor.com/blog/fast-regex-search](https://cursor.com/blog/fast-regex-search)

## Summary

Agents lean heavily on regex search, and ripgrep's full scan can take over 15 seconds in large monorepos, so Cursor builds local indexes specifically to accelerate regex queries. The post traces the lineage of regex indexing: n-gram inverted indexes from Zobel et al. (1993) and Russ Cox's Google Code Search trigram approach, including how regexes are decomposed into trigram AND/OR queries, then livegrep's suffix arrays and GitHub Project Blackbird's trigram posting lists augmented with probabilistic masks (position and next-character bloom filters) to approximate '3.5-grams'. It weighs the tradeoffs of each: index size, query decomposition cost, and difficulty of dynamic updates.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Search](https://swe.quest/tags/search.md) (Backend & APIs)
- [Data structures](https://swe.quest/tags/data-structures.md) (Architecture & design)
- [Algorithms](https://swe.quest/tags/algorithms.md) (Architecture & design)
- [AI agents](https://swe.quest/tags/ai-agents.md) (AI & ML)
- [Developer tools](https://swe.quest/tags/developer-tools.md) (Engineering practices)

## Prerequisites

- regular expressions
- inverted indexes
- bloom filters

## Keywords

ripgrep, trigram index, suffix array, livegrep, zoekt, Project Blackbird, Google Code Search, Cursor

## Related posts

- [A brief history of code search at GitHub](https://swe.quest/articles/a-brief-history-of-code-search-at-github-ac152c8901d98c95.md): GitHub Engineering · 2021-12-15 · Medium · 13 min read · Search, Scaling, Developer tools
  GitHub's code search evolved from a public-only Solr index plus \`git grep\` for private repos, to a decade-long Elasticsearch deployment that grew to 162 nodes, 1.25PB of storage and over 53 billion indexed files.
- [The technology behind GitHub’s new code search](https://swe.quest/articles/the-technology-behind-github-s-new-code-search-7c9e939ab132b5db.md): GitHub Engineering · 2023-02-06 · Medium · 13 min read · Search, Rust, System design, Scaling, Data structures
  GitHub built Blackbird, a Rust code search engine, because general text search engines handled punctuation, regex, and GitHub's scale poorly, and brute-force grep would yield about 0.01 QPS.
- [Introducing pg\_re2, fast, RE2-powered regular expressions in Postgres](https://swe.quest/articles/introducing-pg-re2-fast-re2-powered-regular-expressions-in-postgres-0fcf212bf9544079.md): ClickHouse · 2026-07-08 · Medium · 8 min read · PostgreSQL, Performance engineering, Query engines, Analytics & OLAP
  pg\_re2 is a Postgres extension that replaces backtracking POSIX regex with Google's automata-based RE2 engine, beating Postgres builtins by 1.8x to 8.6x on table scans and 1.1x to 1.8x on index scans.
- [Building a code search engine with Turso](https://swe.quest/articles/building-a-code-search-engine-with-turso-6a98c3f86064a46b.md): Turso · 2026-02-26 · Medium · 6 min read · Vector search, Search, SQLite, AI agents, RAG & retrieval
  Codemogger is an open-source code indexer and search engine for AI agents, built on a single local Turso (SQLite-compatible) file using native vector columns and full-text search.
- [Indexing code at scale with Glean](https://swe.quest/articles/indexing-code-at-scale-with-glean-139998a2186265ba.md): Meta Engineering · 2024-12-19 · Medium · 11 min read · Developer tools, Static analysis, Search, Code review, Open source
  Glean is Meta's open-source code indexing system that stores arbitrary language-specific facts about source code in RocksDB and exposes them through Angle, a declarative logic-based query language that can derive language-neutral views, much like SQL views.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
