Fix missing shifting of Match._textxx fields (#72728)
authorStephen Toub <stoub@microsoft.com>
Tue, 26 Jul 2022 16:40:00 +0000 (12:40 -0400)
committerGitHub <noreply@github.com>
Tue, 26 Jul 2022 16:40:00 +0000 (12:40 -0400)
commitdcf40dd54780414f82a34a2428613f8d5dc0c94a
tree648f96b62199f3e9a71943df0665ddaee9f00849
parentedb30e7a64843b0d91e83b0757b08c61f0403f1b
Fix missing shifting of Match._textxx fields (#72728)

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.
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/Match.cs
src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexRunner.cs
src/libraries/System.Text.RegularExpressions/tests/FunctionalTests/Regex.MultipleMatches.Tests.cs