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
using System.Text.RegularExpressions;
string input = "wtfb";
string pattern="^(.)+()+?b";
Match matchInterpreted = new Regex(pattern, RegexOptions.None).Match(input);
Match matchCompiled = new Regex(pattern, RegexOptions.Compiled).Match(input);
Console.WriteLine($"Interpreted: {matchInterpreted.Value}");
Console.WriteLine($"Compiled: {matchCompiled.Value}");
Output:
Interpreted: b
Compiled: wtfb
Expected behavior
Output:
Interpreted: wtfb
Compiled: wtfb
Actual behavior
Output:
Interpreted: b
Compiled: wtfb
It looks like ()+? would make nearest outside brackets start at where the empty loop began, and this effect maybe gradually spread to group 0 or not.
Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered:
Description
If pattern includes
()+?
, thenRegex.Match(input,pattern)
will match differnetnew Regex(pattern ,RegexOptions.Compiled).Match(input)
Some discussions in GitHub Discussion #110976
Reproduction Steps
Output:
Expected behavior
Output:
Actual behavior
Output:
It looks like
()+?
would make nearest outside brackets start at where the empty loop began, and this effect maybe gradually spread to group 0 or not.Regression?
No response
Known Workarounds
No response
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: