Your requirements are not crystal clear to me. I see that your original program (turned into a Short, Self-Contained, Correct Example):
prints:use strict; use warnings; use Data::Dumper; my $path = '/.snapshots123/yabsm/root/hourly/day=2021_03_04,time=21:20 +'; my $end_of_path; $end_of_path = $1 if $path =~ m/([^\/]+$)/; my @nums = $end_of_path =~ m/([0-9]{2,4})/g; print Dumper( \@nums );
$VAR1 = [ '2021', '03', '04', '21', '20' ];
... as does my simpler version:
Does my version satisfy your requirements?use strict; use warnings; use Data::Dumper; my $path = '/.snapshots123/yabsm/root/hourly/day=2021_03_04,time=21:20 +'; my @nums = $path =~ m{/day=(\d\d\d\d)_(\d\d)_(\d\d),time=(\d\d):(\d\d) +$}; print Dumper( \@nums );
In reply to Re: How can I combine these two regular expressions?
by eyepopslikeamosquito
in thread How can I combine these two regular expressions?
by thirtySeven
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |