Skip to content

Conversation

@stephentoub
Copy link
Member

This regressed during the work to support spans. The Match._textxx fields were set based on the span positions rather than the input string positions, so if the input string had a non-zero beginning value, these fields would be off by that amount. That then impacts NextMatch, as these values are fed into it.

While fixing this, I noticed that the _textstart field was wholely unnecessary and deleted it. I also noticed we were unnecessarily passing around some values that weren't needed (e.g. a runtextbeg value that would always be 0), and re-storing the _regex object that can't ever change, and addressed those.

Fixes #72704

This regressed during the work to support spans.  The Match._textxx fields were set based on the span positions rather than the input string positions, so if the input string had a non-zero beginning value, these fields would be off by that amount.  That then impacts NextMatch, as these values are fed into it.

While fixing this, I noticed that the _textstart field was wholely unnecessary and deleted it.  I also noticed we were unnecessarily passing around some values that weren't needed (e.g. a runtextbeg value that would always be 0), and re-storing the _regex object that can't ever change, and addressed those.
@ghost
Copy link

ghost commented Jul 24, 2022

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

Issue Details

This regressed during the work to support spans. The Match._textxx fields were set based on the span positions rather than the input string positions, so if the input string had a non-zero beginning value, these fields would be off by that amount. That then impacts NextMatch, as these values are fed into it.

While fixing this, I noticed that the _textstart field was wholely unnecessary and deleted it. I also noticed we were unnecessarily passing around some values that weren't needed (e.g. a runtextbeg value that would always be 0), and re-storing the _regex object that can't ever change, and addressed those.

Fixes #72704

Author: stephentoub
Assignees: -
Labels:

area-System.Text.RegularExpressions

Milestone: 7.0.0

Copy link
Member

@joperezr joperezr left a comment

Choose a reason for hiding this comment

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

Great catch @bgrainger and thanks for fixing @stephentoub!

@stephentoub stephentoub merged commit dcf40dd into dotnet:main Jul 26, 2022
@stephentoub stephentoub deleted the fixmatchshift branch July 26, 2022 16:40
@ghost ghost locked as resolved and limited conversation to collaborators Aug 25, 2022
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.

Match.NextMatch returns incorrect Index values for Regex.Match(string, int, int)

2 participants