in reply to How can I combine these two regular expressions?

G'day thirtySeven,

Assuming that's a truly representative $path, you can use this:

$path =~ m/((?<=[=_:])\d+)/g

If you're unfamiliar with (?<=pattern), see "perlre: zero-width positive lookbehind assertion".

Here's an example with your assumed, representative $path:

$ perl -E ' my $path = q{/.snapshots123/yabsm/root/hourly/day=2021_03_04,time= +21:20}; say for $path =~ m/((?<=[=_:])\d+)/g; ' 2021 03 04 21 20

Here's an example where that fails, using a $path that's almost the same as the assumed, representative $path:

$ perl -E ' my $path = q{/.snapshots_23/yabsm/root/hourly/day=2021_03_04,time= +21:20}; say for $path =~ m/((?<=[=_:])\d+)/g; ' 23 2021 03 04 21 20
"only for learning purposes"

Understood. In a real-world application, I'd probably lose the extra text (e.g. day=) and use a simpler format, e.g. YYYY_MM_DD_hh_mm or even just YYYYMMDDhhmm.

— Ken