From eb0ea81933248521ecfefc83b7252834b3573f9b Mon Sep 17 00:00:00 2001 From: Nelson Benitez Leon Date: Wed, 13 Nov 2024 11:19:11 -0400 Subject: [PATCH] Add search syntax tip for whole word searches Whole word searches are very useful in situations when a normal search gives two many false positives. Let's document how to do that in Github code search, so people don't have to look that up in regext tutorials. --- .../understanding-github-code-search-syntax.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/content/search-github/github-code-search/understanding-github-code-search-syntax.md b/content/search-github/github-code-search/understanding-github-code-search-syntax.md index 9c8cf017f5ed..b4a5effc1b32 100644 --- a/content/search-github/github-code-search/understanding-github-code-search-syntax.md +++ b/content/search-github/github-code-search/understanding-github-code-search-syntax.md @@ -316,3 +316,11 @@ By default, code search is case-insensitive, and results will include both upper ```text /(?-i)True/ ``` + +## Whole Words + +If you want your search string to be matched as a whole word, you need to use a regular expression that includes the word boundary token `\b`. For example, to search for the string "True" as a whole word, you would use: + +```text +/\bTrue\b/ +```