Search examples

Below are examples that search repositories on, our open source code search solution for GitHub and GitLab. You can copy and adapt the following search queries for use on your company’s private instance.

See search query syntax reference.

When to use regex search mode

Sourcegraph's default literal search mode is line-based and will not match across lines, so regex can be useful when you wish to do so:

Regex searches are also useful when searching boundaries that are not delimited by code structures:

When to use structural search mode

Use structural search when you want to match code boundaries such as () or {}: