### Description The regex pattern `"(?:|a?|b)+?c"` applied to `"a"` does not terminate on interpreted regex. ### Reproduction Steps ```c# using System; using System.Text.RegularExpressions; var re = new Regex("(?:|a?|b)+?c", RegexOptions.None); Console.WriteLine(re.IsMatch("a")); ``` https://dotnetfiddle.net/oe7YtN ### Expected behavior This should print `false` ### Actual behavior It loops infinitely (or runs out of memory as it does on dotnetfiddle) ### Regression? IDK ### Known Workarounds Compiled regex does not hang (`RegexOptions.None` swapped for `RegexOptions.Compiled`) ```c# using System; using System.Text.RegularExpressions; var re = new Regex("(?:|a?|b)+?c", RegexOptions.Compiled); Console.WriteLine(re.IsMatch("a")); ``` ### Configuration .NET 10.0.12 macOS 27.0 ARM64 ### Other information The pattern `"(?:|a*|b)*?c"` applied to `"a"` has the same behavior and is likely the same bug.
Activity
dotnet-policy-service commentedon Oct 7, 2026
Tagging subscribers to this area: @dotnet/area-system-text-regularexpressions
See info in area-owners.md if you want to be subscribed.
MihaZupan commentedon Oct 7, 2026
Have you tried to reproduce the issue on .NET 11? This may have been fixed by #120872
hez2010 commentedon Oct 8, 2026
Doesn't seem to repro on .NET 11.
It does repro on .NET 10 though.
MihaZupan commentedon Oct 19, 2026
I'll close this as fixed, feel free to comment again if you see otherwise