Skip to content

Regex interpreter and compiler disagree on pattern with empty alternate #135330

Closed

Description

@robertmorelli

Description

The regex pattern "(?:(?:c|)+?b){2}a" incorrectly fails to match matches on "bba" interpreted regex (but works fine on compiled regex)

Reproduction Steps

using System;
using System.Text.RegularExpressions;
var re = new Regex("(?:(?:c|)+?b){2}a", RegexOptions.None);
Console.WriteLine(re.IsMatch("bba"));

https://dotnetfiddle.net/nrUjts

Expected behavior

should print true

Actual behavior

prints false

Regression?

IDK

Known Workarounds

use RegexOptions.Compiled

Configuration

.NET 10.0.12
macOS 27.0
ARM64

Other information

could be related to #135328

Activity

  1. added
    untriaged
    on Oct 7, 2026
  2. dotnet-policy-service commented on Oct 7, 2026

    @dotnet-policy-service
    Contributor

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

  3. MihaZupan commented on Oct 7, 2026

    @MihaZupan
    Member

    Also may have been fixed by #120872

  4. MihaZupan commented on Oct 19, 2026

    @MihaZupan
    Member

    I'll close this as fixed, feel free to comment again if you see otherwise

  5. removed
    untriaged
    on Oct 19, 2026
  6. locked and limited conversation to collaborators on Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions