Skip to content
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

Fix handling of \G in Regex.Split/Replace #44975

Merged
merged 1 commit into from
Nov 20, 2020

Conversation

stephentoub
Copy link
Member

In our optimized Regex.Split/Replace loop, we failed to update runtextstart, which means the \G anchor (aka starting where the previous match ended) would fail to match after the first one because it would be attempting to match at the initial start rather than where the last match left off.

One-line fix to up the field correctly, and then some tests.

Fixes #44957

In our optimized Regex.Split loop, we failed to update runtextstart, which means the \G anchor (aka starting where the previous match ended).
@ghost
Copy link

ghost commented Nov 20, 2020

Tagging subscribers to this area: @eerhardt, @pgovind, @jeffhandley
See info in area-owners.md if you want to be subscribed.

Issue Details

In our optimized Regex.Split/Replace loop, we failed to update runtextstart, which means the \G anchor (aka starting where the previous match ended) would fail to match after the first one because it would be attempting to match at the initial start rather than where the last match left off.

One-line fix to up the field correctly, and then some tests.

Fixes #44957

Author: stephentoub
Assignees: -
Labels:

area-System.Text.RegularExpressions

Milestone: 6.0.0

Copy link

@pgovind pgovind left a comment

Choose a reason for hiding this comment

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

Ah, simple. LGTM

@stephentoub
Copy link
Member Author

/backport to release/5.0

@stephentoub stephentoub merged commit cb80f85 into dotnet:master Nov 20, 2020
@stephentoub stephentoub deleted the fixsplit branch November 20, 2020 05:07
@github-actions
Copy link
Contributor

Started backporting to release/5.0: https://github.com/dotnet/runtime/actions/runs/373715607

@ghost ghost locked as resolved and limited conversation to collaborators Dec 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regex.Split() with \G stops after first item
2 participants