Skip to content

Regular expressions

Enable Use regex in Search to match a pattern instead of literal text. Enter the pattern without surrounding / delimiters. Patterns are case-sensitive by default.

PatternMatches
api[_-]?keyapikey, api_key, api-key
(?i)api[_-]?keyThe same forms regardless of letter case
`(stagingproduction)[_-]url`
https://api[.]example[.]comA particular API host
TOKEN[ \t]*=[ \t]*["'][A-Za-z0-9_-]{16,}["']An illustrative token-like assignment

These are query examples, not detectors that validate credentials. Adapt markers to the system you are investigating.

. means any character in regex. Write [.] or \. for a literal dot. Other metacharacters include *, +, ?, (, ), [, ], {, }, ^, $, and |. Leave Use regex off when you simply want an exact phrase.

Interactive Search uses RE2 syntax. Lookahead, lookbehind, and backreferences are not supported. Prefer explicit alternatives and character classes. Read the RE2 syntax reference for the complete grammar.

Start with a distinctive literal segment and add only the variation needed. A broad pattern may reach the visible match limit before the files you want are returned.

Repository and file-type filters narrow already received results. GitHub-style repo: and path: operators are not parsed by the main query box.

The customer code-search API currently accepts literal queries only. Do not send a regex flag to that API.

Watchdogs use Python regex for their contains regex condition. Test your intended semantics separately when translating between Search and a monitor.