You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regex filter never matches blank text under the default ByWordAny: IsMatch(" ", @"\s", Regex) and IsMatch("", "^$", Regex) return false #193
Under the default TextFilterMatchOptions.ByWordAny, a regex filter can't match text that is empty or only whitespace, even when the pattern is written to match exactly that:
So a "find the blank entries" filter such as ^\s*$ or \s+ misses exactly the entries it is looking for, but only under the default option. The same pattern does match whitespace when the text also contains a word.
I checked this with a scratch MSTest against main at 5f420d9.
Cause
In DoesMatchRegex (TextFilter/TextFilter.cs:735-746), the early return for blank text comes before the ByWordAny whole-text attempt:
if(textTokens.Count==0){returnfalse;// added for #107/#109 so ByWordAll isn't vacuously true}if(textFilterMatchOptionsisTextFilterMatchOptions.ByWordAny&&IsMatchWithinTimeout(refactiveRegex,cacheKey,text)){returntrue;// added for #125: patterns that span whitespace match the whole text}
Blank text splits into zero words, so the function returns before the whole text is ever matched. The early return was only needed for ByWordAll, where Enumerable.All over an empty set is vacuously true.
Suggested fix
Move the ByWordAny whole-text check above the textTokens.Count == 0 return, or limit that return to ByWordAll. Either way, #107/#109 stays fixed: under ByWordAll, blank text still matches nothing.
Acceptance criteria
IsMatch(" ", @"\s", Regex) and IsMatch("", "^$", Regex) return true under ByWordAny
Priority: Medium. It happens under the default ByWordAny option, and it makes "find the blank entries" regex filters (^\s*$, \s+) miss exactly the items they target. The fix is a small reorder.
Activity
matt-edmondson commentedon Nov 6, 2026
Triage
ByWordAnyoption, and it makes "find the blank entries" regex filters (^\s*$,\s+) miss exactly the items they target. The fix is a small reorder.DoesMatchRegexinTextFilter/TextFilter.cs. The interaction is between the Regex + ByWordAll matches empty or whitespace-only text against any pattern #107/Stop regex ByWordAll matching blank text #109 empty-token guard and the Let a regex that spans whitespace match under ByWordAny [patch] #125 whole-text attempt.DoesMatchRegex. The open TextFilter PRs (Match an unclosed glob bracket literally [patch] #165, Match a mixed-case glob range the same under both case sensitivities [patch] #168, Match a whole-string glob containing a space against the whole text [patch] #169, Mask / and \ to different characters in glob matching [patch] #175, Hold only the visible overloads to the README's documented defaults [patch] #186, Count only doubled **/ against the zero-segment expansion cap [patch] #187, Keep case-sensitive globs off DotNet.Glob's global default [patch] #189, Match the empty remainder with a trailing whole-segment ** [patch] #192) are about globs or the README test.textTokens.Count == 0early return toByWordAll, or move the ByWordAny whole-text check above it. Add blank and whitespace-only cases under both options, and keep the Regex + ByWordAll matches empty or whitespace-only text against any pattern #107/Stop regex ByWordAll matching blank text #109 tests passing.Generated by Claude Code