(Warning: more Regexp::Assemble pimping ahead).
Assuming you do not really care about those captures, if I "unroll" the patterns, it looks like you're interested matching against the following patterns:
^\d{8}\.ilf ^\d{8}_\d+\.ilf ^\d{8}\.sht ^\d{8}\s\d+\.sht
Using the assemble script from the above module, or something like
my $re = Regexp::Assemble->new(flags=>'i')->add(@list)it produces the following pattern:
^\d{8}(?:\.(?:ilf|sht)|\s\d+\.sht|_\d+\.ilf)... which looks roughly like that the other people came up with manually. If you do need the captures, the pattern becomes
^\d{8}(?:(\s(\d+))\.sht|(_(\d+))\.ilf|\.(?:ilf|sht))in which case you can perform the match and get the captures with something like
my @result = map {defined} ($file =~ /$re/);• another intruder with the mooring in the heart of the Perl
In reply to Re: File name regex
by grinder
in thread File name regex
by dev2dev
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |