I'm writing a node.js script to group tons of screenshots.
I have got two different patterns that I want to match:
/(?<date>\d{4}-\d{2}-\d{2}) (?<time>\d{2}_\d{2}_\d{2})(-| - )(?<window>.*?)(-| - )(?<index>\d{6})(?<extension>\.(png|jpg|jpeg))/g
/(?<date>\d{4}-\d{2}-\d{2}) (?<time>\d{2}_\d{2}_\d{2})(-| - )(?<window>.*?)(?<extension>\.(png|jpg|jpeg))/g
- '2017-08-31 18_57_42-shouldwork.png' matches 2nd as expected
- '2017-08-31 18_57_43-shouldwork.png' does not match either
- '2017-08-31 18_57_42-shouldwork - Kopie.png' matches 2nd as expected
- '2017-08-31 18_57_42-shouldwork2.png' does not match
- '2019-03-09 11_11_09 - shouldwork - 000003.png' matches 1st as expected
- '2019-03-09 11_11_10 - shouldwork - 000003.png' matches 2nd
- 'should fail.png' does not match either as expected
Here is also fiddle where you can see it with my code (reduced to the problematic parts) https://jsfiddle.net/sfwr750n/
and here is a link to regex101 https://regex101.com/r/dxGFNN/1
At first I thought it was just node.js, but Chrome has the same problem (didn't try firefox, last time I checked it didn't support named groups), even more confusing is the fact that regex101 matches everything as expected.