搜尋檔案內容
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
根據預設,查詢會同時搜尋檔案路徑和內容。您可以使用 content
篩選器,將搜尋範圍限制為檔案內容。例如,以下查詢是在所有 Java 檔案的內容中尋找字詞 main
。系統不會搜尋路徑包含字詞 main
的執行個體。
lang:java content:main
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-07-26 (世界標準時間)。
[null,null,["上次更新時間:2025-07-26 (世界標準時間)。"],[[["\u003cp\u003eThe default search includes both file paths and file content.\u003c/p\u003e\n"],["\u003cp\u003eFor content-only searches, use the \u003ccode\u003econtent\u003c/code\u003e filter, like \u003ccode\u003econtent:main\u003c/code\u003e to find "main" within Java files.\u003c/p\u003e\n"],["\u003cp\u003eThis approach avoids irrelevant results from file paths containing the search term.\u003c/p\u003e\n"]]],[],null,["# Searching file contents\n\nBy default, a query searches both the file path and the content. You can\nrestrict your search to just the contents of a file by using the\n[`content`](../reference#filters) filter. For example, the following query looks\nfor the term `main` in the contents of all Java files. It does not search for\ninstances where a path contains the term `main`. \n\n lang:java content:main"]]