Skip to content

Add tests for lazy quantifier inside optional group#125474

Merged
danmoseley merged 1 commit intodotnet:mainfrom
stephentoub:regex-lazy-optional-group-test
Mar 12, 2026
Merged

Add tests for lazy quantifier inside optional group#125474
danmoseley merged 1 commit intodotnet:mainfrom
stephentoub:regex-lazy-optional-group-test

Conversation

@stephentoub
Copy link
Member

Add test cases for the pattern a(b.*?c)?d to confirm the fix from #124254 addresses the regression reported in #125321, where a lazy quantifier inside an optional group incorrectly failed to match.

Tests cover:

  • Lazy must expand: abccd — lazy .*? must grow past first c for d to match
  • Lazy zero-width: abcd — lazy .*? matches nothing, c and d align immediately
  • Optional group skipped: ad — the entire (b.*?c)? group is bypassed
  • No match: abce — no d available, match correctly fails

Add test cases for the pattern a(b.*?c)?d to confirm the fix from PR dotnet#124254 addresses the regression reported in dotnet#125321, where a lazy quantifier inside an optional group incorrectly failed to match.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dotnet-policy-service
Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds four test cases for the regex pattern a(b.*?c)?d to the existing Match_MemberData_Cases test data provider, verifying the fix from PR #124254 for the regression reported in issue #125321 where a lazy quantifier inside an optional group incorrectly failed to match.

Changes:

  • Added four yield return entries covering lazy-must-expand, lazy-zero-width, optional-group-skipped, and no-match scenarios for the a(b.*?c)?d pattern.

You can also share your feedback on Copilot code review. Take the survey.

@danmoseley danmoseley merged commit bc449db into dotnet:main Mar 12, 2026
99 of 100 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants