Home / Engine / Use cases

A regex search API that doesn't scan everything

Most search engines can't run a regex across a whole document, and the ones that can scan every byte. StackGrep indexes your text so a pattern only reads the documents that could match, then checks them with a linear-time engine that no pattern can make run away.

Join the waitlist See the docs

Why the usual way falls short

  • Search engines match regexes one word at a time, not across text
  • Scanning with grep or a database LIKE gets slower with every gigabyte
  • Backtracking regex engines can hang on one bad pattern

How it looks

curl -G https://stackgrep.com/api/collections/code/search \
  -H "Authorization: Bearer $STACKGREP_KEY" \
  --data-urlencode 'q=AKIA[0-9A-Z]{16}' -d regex=1

# and exactly how many there are
curl -G https://stackgrep.com/api/collections/code/count ... -d regex=1

What your agent asks, and what it calls

“Find anything that looks like an AWS access key”search_collection(query: "AKIA[0-9A-Z]{16}", regex: true)
“Which invoices total over 10,000 EUR?”search_collection(query: "Total: [0-9]{2},[0-9]{3}(\.[0-9]{2})? EUR", regex: true)
“How many log lines have a 5xx status?”count_collection(query: " 5[0-9]{2} ", regex: true)

Questions

What regex syntax is supported?

RE2-style syntax: character classes, alternation, repetition, anchors and groups. No backreferences or lookarounds, which is what keeps every search linear-time.

How can a regex be fast on lots of text?

We pull the literal pieces out of your pattern (AKIA, EUR, max_connections) and use the index to find only the documents containing them. Only those get the full regex.

Is there a limit on pattern complexity?

No pattern can blow up: the engine runs in time proportional to the text it reads. Patterns with no literal part at all, like [0-9]+, have to read everything, so they're slower.

More use cases

Give your agents exact search

StackGrep Engine is onboarding teams from the waitlist. Bring your documents or your bucket.

Join the waitlist Read the docs