Skip to content

Add a regex test for a loop followed by a positive lookahead #118142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

stephentoub
Copy link
Member

Locally I made a change (allowing loops to be made atomic based on a positive lookahead after them) that should have failed tests but didn't. This adds a test that would have caught the issue.

Locally I made a change (allowing loops to be made atomic based on a positive lookahead after them) that should have failed tests but didn't. This adds a test that would have caught the issue.
@stephentoub stephentoub requested review from MihaZupan and Copilot July 28, 2025 21:28
Copy link
Contributor

@Copilot 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 a regression test for regex patterns that combine loops with positive lookahead assertions. The test ensures that a specific pattern involving a*(?=b)\bb correctly matches against the input "ab", which would help catch issues where loop optimizations incorrectly interact with lookahead assertions.

Comments suppressed due to low confidence (1)

src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.Match.Tests.cs:101

  • The test case pattern a*(?=b)\bb appears to test a very specific edge case. Consider adding additional test cases with different variations of loops and positive lookaheads (e.g., a+(?=b)\bb, a{2,}(?=b)\bb) to ensure comprehensive coverage of the optimization behavior being tested.
                yield return (@"a*(?=b)\bb", "ab", RegexOptions.None, 0, 2, true, "ab");

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.

@stephentoub stephentoub deleted the addregextest branch July 29, 2025 01:20
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.

2 participants