GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing docs.github.com — Understanding GitHub Code Search syntax - GitHub Docs Understanding GitHub Code Search syntaxYou can build search queries for the results you want with specialized code qualifiers, regular expressions, and boolean operations. In this articleAbout code search query structureThe search syntax in this article only applies to searching code with GitHub code search. Note that the syntax and qualifiers for searching for non-code content, such as issues, users, and discussions, is not the same as the syntax for code search. For more information on non-code search, see About searching on GitHub and Searching on GitHub. Search queries consist of search terms, comprising text you want to search for, and qualifiers, which narrow down the search. A bare term with no qualifiers will match either the content of a file or the file's path. For example, the following query:
The above query will match the file You can enter multiple terms separated by whitespace to search for documents that satisfy both terms. For example, the following query:
The search results would include all documents containing both the terms Searching for multiple terms separated by whitespace is the equivalent to the search Code search also supports searching for an exact string, including whitespace. For more information, see Query for an exact match. You can narrow your code search with specialized qualifiers, such as You can also use regular expressions in your searches by surrounding the expression in slashes. For more information on using regular expressions, see Using regular expressions. Query for an exact matchTo search for an exact string, including whitespace, you can surround the string in quotes. For example:
You can also use quoted strings in qualifiers, for example:
Searching for quotes and backslashesTo search for code containing a quotation mark, you can escape the quotation mark using a backslash. For example, to find the exact string
To search for code containing a backslash, The two escape sequences Additional escape sequences, such as Using boolean operationsCode search supports boolean expressions. You can use the operators By default, adjacent terms separated by whitespace are equivalent to using the To search for documents containing either one term or the other, you can use the
To exclude files from your search results, you can use the
You can use parentheses to express more complicated boolean expressions. For example:
Using qualifiersYou can use specialized keywords to qualify your search.
Repository qualifierTo search within a repository, use the
To search within a set of repositories, you can combine multiple
Note
Code search does not currently support regular expressions or partial matching for repository names, so you will have to type the entire repository name (including the user prefix) for the Organization and user qualifiersTo search for files within an organization, use the
To search for files within a personal account, use the
Note Code search does not currently support regular expressions or partial matching for organization or user names, so you will have to type the entire organization or user name for the qualifier to work. Enterprise qualifierTo search for files within an enterprise, use the
This searches repositories owned by organizations in the Language qualifierTo narrow down to a specific language, use the
For a complete list of supported language names, see languages.yaml in github-linguist/linguist. If your preferred language is not on the list, you can open a pull request to add it. License qualifierTo filter repositories based on their license or license family, use the
See Licensing a repository for a list of license keywords. Path qualifierTo search within file paths, use the
The above query will match both To match only a specific filename (and not part of the path), you could use a regular expression:
Note that the You can also use some limited glob expressions in the For example, to search for files with the extension
To search for JavaScript files within a `src` directory, you could use:
You can also use the
To search for a filename which contains a special character like `*` or `?`, just use a quoted string:
Glob expressions are disabled for quoted strings, so the above query will only match paths containing the literal string Symbol qualifierYou can search for symbol definitions in code, such as function or class definitions, using the For example, to search for a symbol called
In some languages, you can search for symbols using a prefix (e.g. a prefix of their class name). For example, for a method You can also use regular expressions with the symbol qualifier. For example, the following query would find conversions people have implemented in Rust for the
Note that this qualifier only searches for definitions and not references, and not all symbol types or languages are fully supported yet. Symbol extraction is supported for the following languages:
We are working on adding support for more languages. If you would like to help contribute to this effort, you can add support for your language in the open source Tree-sitter parser ecosystem, upon which symbol search is based. Content qualifierBy default, bare terms search both paths and file content. To restrict a search to strictly match the content of a file and not file paths, use the
This query would only match files containing the term Is qualifierTo filter based on repository properties, you can use the
For example:
Note that the
To exclude forks from your results, you can search:
Using regular expressionsCode search supports regular expressions to search for patterns in your code. You can use regular expressions in bare search terms as well as within many qualifiers, by surrounding the regex in slashes. For example, to search for the regular expression
Note that you'll have to escape any forward slashes within the regular expression. For example, to search for files within the
Inside a regular expression, Most common regular expressions features work in code search. However, "look-around" assertions are not supported. Separating search termsAll parts of a search, such as search terms, exact strings, regular expressions, qualifiers, parentheses, and the boolean keywords If your search contains multiple components that aren't separated by spaces, or other text that does not follow the rules listed above, code search will try to guess what you mean. It often falls back on treating that component of your query as the exact text to search for. For example, the following query:
Code search will give up on interpreting the parentheses and quotes as special characters and will instead search for files containing that exact code. If code search guesses wrong, you can always get the search you wanted by using quotes and spaces to make the meaning clear. Case sensitivityBy default, code search is case-insensitive, and results will include both uppercase and lowercase results. You can do case-sensitive searches by using a regular expression with case insensitivity turned off. For example, to search for the string "True", you would use: |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |