This is the test. I expect the last group to be ".png"
, but this pattern returns ""
instead.
var inputStr = @"C:\path\to\dir\[yyyy-MM-dd_HH-mm].png";
var pattern = @"(.*?)\[(.*?)\](.*?)";
var regex = new Regex(pattern);
var match = regex.Match(inputStr);
var thirdGroupValue = match.Groups[3].Value;
// ✓ EXPECTED: ".png"
// ✗ CURRENT: ""
The 1st and 2nd groups work fine.