Skip to content

Commit b5b7dea

Browse files
authored
Search: clarify file filter description (#682)
This PR clarifies the description of the `file:regexp-pattern` search filter. The regexp is not anchored by default, and can match against any substring of the path. Resolves this thread: https://sourcegraph.slack.com/archives/C05R619V4F8/p1727689383280839
1 parent f698968 commit b5b7dea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/code-search/queries/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ The following filters can be used on all searches (using [RE2 syntax](https://go
5151
| **repo:regexp-pattern** <br /> **repo:regexp-pattern@rev** <br /> **repo:regexp-pattern rev:rev**<br />_alias: r_ | Include results from repos whose path matches a specified regexp-pattern. The repo path is `github.com/myteam/abc` or `code.example.com/xyz` depending on your repo host. If the regexp ends in `@rev`, search that revision instead of the default `main` branch. `repo:regexp-pattern@rev` is equivalent to `repo:regexp-pattern rev:rev` | [`repo:gorilla/mux testroute`](https://sourcegraph.com/search?q=repo:gorilla/mux+testroute) <br/> [`repo:^github\.com/sourcegraph/[email protected] mux`](https://sourcegraph.com/search?q=repo:%5Egithub%5C.com/sourcegraph/sourcegraph%24%40v3.14.0+mux&patternType=keyword) |
5252
|**-repo:regexp-pattern** <br /> _alias: -r_ | Exclude results from repositories whose path matches the regexp | `repo:alice/ -repo:old-repo` |
5353
| **rev:revision-pattern** <br /> _alias: revision_ | Search a revision instead of the default branch. `rev:` can only be used in conjunction with `repo:` and may not be used more than once. See our [revision syntax](#repository-revisions) documentation to learn more | [`repo:sourcegraph/sourcegraph rev:v3.14.0 mux`](https://sourcegraph.com/search?q=repo:sourcegraph/sourcegraph+rev:v3.14.0+mux&patternType=keyword) |
54-
| **file:regexp-pattern** <br /> _alias: f_ | Only include results in files whose full path matches the regexp | [`file:\.js$ httptest`](https://sourcegraph.com/search?q=file:%5C.js%24+httptest) <br /> [`file:internal/ httptest`](https://sourcegraph.com/search?q=file:internal/+httptest) |
55-
| **-file:regexp-pattern** <br /> _alias: -f_ | Exclude results from files whose full path matches the regexp | [`file:\.js$ -file:test http`](https://sourcegraph.com/search?q=file:%5C.js%24+-file:test+http) |
54+
| **file:regexp-pattern** <br /> _alias: f_ | Only include file results whose full path matches the regexp. The regexp is unanchored by default: to match against the entire path, use regexp anchors like `^README.md$`. | [`file:\.js$ httptest`](https://sourcegraph.com/search?q=file:%5C.js%24+httptest) <br /> [`file:internal/ httptest`](https://sourcegraph.com/search?q=file:internal/+httptest) |
55+
| **-file:regexp-pattern** <br /> _alias: -f_ | Exclude file results whose full path matches the regexp. The regexp is unanchored by default: to match against the entire path, use regexp anchors like `^README.md$`. | [`file:\.js$ -file:test http`](https://sourcegraph.com/search?q=file:%5C.js%24+-file:test+http) |
5656
| **content:"pattern"** | Set the search pattern with a dedicated parameter. Useful when searching literally for a string that may conflict with the [search pattern syntax](#search-pattern-syntax). In between the quotes, the `\` character will need to be escaped (`\\` to evaluate for `\`) | [`repo:sourcegraph content:"repo:sourcegraph"`](https://sourcegraph.com/search?q=repo:sourcegraph+content:"repo:sourcegraph"&patternType=keyword) |
5757
| **-content:"pattern"** | Exclude results from files whose content matches the pattern. | [`file:Dockerfile alpine -content:alpine:latest`](https://sourcegraph.com/search?q=file:Dockerfile+alpine+-content:alpine:latest&patternType=keyword) |
5858
| **select:_result-type_** <br /> **select:repo** <br /> **select:commit.diff.added** <br /> **select:commit.diff.removed** <br /> **select:file** <br /> **select:content** <br /> **select:symbol._symbol-type_** <br /> **select:file.owners** _(Experimental)_ | Shows only query results for a given type. For example, `select:repo` displays only distinct repository paths from search results, and `select:commit.diff.added` shows only added code matching the search. See [language definition](/code-search/queries/language#select) for full list of possible values | [`fmt.Errorf select:repo`](https://sourcegraph.com/search?q=fmt.Errorf+select:repo&patternType=keyword) |

0 commit comments

Comments
 (0)