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.
Useful patterns
Section titled “Useful patterns”| Pattern | Matches |
|---|---|
api[_-]?key | apikey, api_key, api-key |
(?i)api[_-]?key | The same forms regardless of letter case |
| `(staging | production)[_-]url` |
https://api[.]example[.]com | A 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.
Literal characters
Section titled “Literal characters”. 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.
RE2 compatibility
Section titled “RE2 compatibility”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.
Filters are a separate step
Section titled “Filters are a separate step”Repository and file-type filters narrow already received results. GitHub-style repo: and path: operators are not parsed by the main query box.
API and monitoring differences
Section titled “API and monitoring differences”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.