Skip to content

Match blank text with a blank-text regex under ByWordAny [patch] - #195

Open
matt-edmondson wants to merge 2 commits into
mainfrom
fix/regex-blank-text-193
Open

matt-edmondson wants to merge 2 commits into
mainfrom
fix/regex-blank-text-193

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #193

What was wrong

DoesMatchRegex returned false for text with no words ("", " ") before it tried the ByWordAny whole-text match added for #125. As a result, a regex written to find blank entries (^\s*$, \s+, ^$) missed exactly those entries under the default ByWordAny, even though it matched them under ByWholeString.

Change

The ByWordAny whole-text attempt now runs before the no-words return. That return stays in place for ByWordAll, so blank text still can't match vacuously there (#107/#109).

Tests

  • RegexByWordAnyMatchesBlankTextWithAPatternForBlankText: six blank or whitespace-only texts against blank-finding patterns, under ByWordAny and ByWholeString.
  • RegexByWordAllStillMatchesNoBlankText: the same kind of patterns still match nothing under ByWordAll.
  • RegexByWordAnyDoesNotMatchBlankTextWithAPatternThatNeedsAWord: zzz and \w still don't match blank text.
  • RegexByWordAnyFilterKeepsTheBlankEntries: Filter with ^\s*$ keeps "" and " " and drops the rest.
  • With the TextFilter.cs change reverted, 7 of the new cases fail. The ByWordAll and needs-a-word cases pass either way and stay in as guards.
  • Full suite on Linux / .NET 10: 279/280. The one failure, EveryMethodInTheReadmeApiReferenceExistsWithItsDocumentedDefaults, fails the same way on main at 5f420d9 and is addressed by Hold only the visible overloads to the README's documented defaults [patch] #186.

Generated by Claude Code

DoesMatchRegex returned false for text with no words before it tried the
ByWordAny whole-text match, so a filter written to find blank entries
(`^\s*$`, `\s+`, `^$`) missed exactly those under the default option.

The whole-text attempt now comes first. The no-words return still stops
ByWordAll matching blank text vacuously (#107/#109).

Fixes #193

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW5JaSLvVsxrZiNZpKh
EveryMethodInTheReadmeApiReferenceExistsWithItsDocumentedDefaults fails on
main at 5f420d9. This is #186's change, verbatim, so the two merge cleanly
whichever lands first.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017vfJW5JaSLvVsxrZiNZpKh

Copy link
Copy Markdown
Contributor Author

ci / .NET / Test on ubuntu-latest failed on EveryMethodInTheReadmeApiReferenceExistsWithItsDocumentedDefaults. This PR didn't cause it. The same test fails on main at 5f420d9 (CI runs 96, 104 and 107 are all red), and this PR doesn't touch the README or its test.

The fix already exists in #186, and it is test-only, so 28b8ef4 ports it here verbatim. Whichever of the two PRs lands first, the other merges cleanly. Locally, 280/280 tests now pass.


Generated by Claude Code

@sonarqubecloud

sonarqubecloud Bot commented Nov 6, 2026

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
D Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copy link
Copy Markdown
Contributor Author

All tests on Windows, Linux and macOS, plus Analyze & Release, are green at 28b8ef4. The only red check is SonarCloud Code Analysis (D maintainability rating on new code), and this PR didn't cause it:


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regex filter never matches blank text under the default ByWordAny: IsMatch(" ", @"\s", Regex) and IsMatch("", "^$", Regex) return false

2 participants