Skip to content

BUG? Different Behavior of Balancing Groups in Interpreted and Compiled Modes #111630

Closed

Description

@longxya

Description

For the expression (?'name1-name2'), when entering balancing group (?'name1-name2', it will check if name2 has a capture in compiled RegularExpression, whereas it does nothing in interpreted mode.

Reproduction Steps

using System;
using System.Text.RegularExpressions;

var pattern = @"(?'2-1'(.))";
var input = @"1";
Match matchInterpreted = new Regex(pattern, RegexOptions.None).Match(input);
Match matchCompiled = new Regex(pattern, RegexOptions.Compiled).Match(input);
Console.WriteLine($"Interpreted: {matchInterpreted.Success}");
Console.WriteLine($"Compiled: {matchCompiled.Success}");

Output:

Interpreted: True
Compiled: False

Expected behavior

Output:

Interpreted: True
Compiled: True

or

Interpreted: False
Compiled: False

Actual behavior

OUtput:

Interpreted: True
Compiled: False

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Activity

  1. added
    untriaged
    on Jan 20, 2025
  2. dotnet-policy-service commented on Jan 20, 2025

    @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. added
    in-pr
    and removed
    untriaged
    on Jan 23, 2025
  4. stephentoub commented on Jan 23, 2025

    @stephentoub
    Member

    Thanks. Will be fixed by #111769.

  5. added this to the 10.0.0 milestone on Jan 27, 2025
  6. locked and limited conversation to collaborators on Feb 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-System.Text.RegularExpressionsbugin-pr

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions