KEMBAR78
Regex conditional groups are broken if no "else" expression is given · Issue #24894 · dotnet/runtime · GitHub
Skip to content

Regex conditional groups are broken if no "else" expression is given #24894

@kendfrey

Description

@kendfrey

Scenario:

Match match = Regex.Match("abc", "(?(?=x)bx)");
Console.WriteLine("Success: {0}", match.Success);
Console.WriteLine("Value: \"{0}\"", match.Value);
Console.WriteLine("Index: {0}", match.Index);

Output:

Success: True
Value: ""
Index: 1

Expected result:

I don't know. If leaving out the "else" expression isn't supported, it should throw an exception. Otherwise, matching anywhere seems the most reasonable option. In any case, if the condition fails, the result should not depend on the contents of the "if" expression.

Additional notes:

https://stackoverflow.com/q/48574288/785745

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions