You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(?(wtf)(?i)wtf) and (?(?i:wtf)wtf) can't run in .NET v5、v6、v7、v8、v9 cause it directly contain regex options. But it works in lower versions.
Reproduction Steps
using System;
using System.Text.RegularExpressions;
var pattern = @"(?(wtf)(?i)wtf)";
//pattern = @"(?(wtf)(?i:wtf))";// this behavior same as the expression above
var input = @"11";
try
{
Match matchCompiled = new Regex(pattern, RegexOptions.None).Match(input);
Console.WriteLine($"Interpreted: {matchCompiled.Success}");
}catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
try
{
Match matchCompiled = new Regex(pattern, RegexOptions.Compiled).Match(input);
Console.WriteLine($"Compiled: {matchCompiled.Success}");
}catch(Exception ex)
{
Console.WriteLine(ex.Message);
}
Output:
Invalid pattern '(?(wtf)(?i)wtf)' at offset 10. Unrecognized grouping construct.
Invalid pattern '(?(wtf)(?i)wtf)' at offset 10. Unrecognized grouping construct.
Expected behavior
Output:
Interpreted: True
Compiled: True
Actual behavior
OUtput:
Invalid pattern '(?(wtf)(?i)wtf)' at offset 10. Unrecognized grouping construct.
Invalid pattern '(?(wtf)(?i)wtf)' at offset 10. Unrecognized grouping construct.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered:
@danmoseley, this was disabled in dotnet/corefx#16609. It's not clear to me why, other than as an easy fix for addressing some parsing errors. Was it intentionally blocked off, including prohibiting quantifiers as part of the conditional's if/else expressions and not just the test expression?
Description
(?(wtf)(?i)wtf)
and(?(?i:wtf)wtf)
can't run in .NET v5、v6、v7、v8、v9 cause it directly contain regex options. But it works in lower versions.Reproduction Steps
Output:
Expected behavior
Output:
Actual behavior
OUtput:
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: