I am running the following snippet of code on Perl 5.22:
DB<41> x "up 34 days, 22:04 and more" =~ m/.*?(?:(\d+) days).*$/
0 34
The above code works as expected and pulls out the 34 from "34 days".
My question comes in when I make the capture group optional by adding a ? at the end of it like this:
DB<4> x "up 34 days, 22:04 and more" =~ m/.*?(?:(\d+) days)?.*$/
0 undef
Why does it no longer match the 34? I have searched the web, but couldn't find any questions that matched mine (if you do have a link that explains it, that would be fantastic).
Thanks, in advance, for your time.