-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Regex.Match fails for the .* pattern when startat is non-zero #42390
Comments
Tagging subscribers to this area: @eerhardt, @pgovind, @jeffhandley |
@slozier, thanks for the very helpful repro. This is due to #1706. That PR adds an optimization that automatically adds a beginning-of-line anchor to a pattern that begins with The simple fix is to just delete the optimization, i.e. remove this code: runtime/src/libraries/System.Text.RegularExpressions/src/System/Text/RegularExpressions/RegexNode.cs Lines 353 to 403 in a747fee
That removes a valuable optimization, but I'm not sure if there's a good way to save it. One thought is to add a new kind of anchor, one that behaves like BOL for the purposes of jumping ahead in FindFirstChar but that doesn't actually require any matching in Go. I expect that would work, but it's probably too late to do so for .NET 5. @pgovind, @danmosemsft, thoughts? |
Description
Regex.Match fails for
.*
pattern whenstartat
is non-zero. I would expect the following to succeed but it does not.Configuration
.NET SDK (reflecting any global.json):
Version: 5.0.100-rc.1.20452.10
Commit: 473d1b592e
Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\5.0.100-rc.1.20452.10\
Host (useful for support):
Version: 5.0.0-rc.1.20451.14
Commit: 38017c3
Regression?
This works in .NET Core 3.1 and .NET Framework.
The text was updated successfully, but these errors were encountered: