http://www.perlmonks.org?node_id=998756


in reply to Re^2: Another Pattern Matching Question
in thread Another Pattern Matching Question

Or like this: (I've tried so many combinations I'm confusing myself!)
if ($fileName =~ /3B4[0|1|2]RT\.\d{10}\.7R.bin/) { ($product, $year, $month, $day, $hour, $ver) = ($fileName =~ /(3B4.RT)\.(\d{4})(\d\d)(\d\d)(\d\d)\.(7R)\.bin/); $version = sprintf "%03d", $ver; # a little confusing, $version +is global # $ver is local

Replies are listed 'Best First'.
Re^4: Another Pattern Matching Question
by runrig (Abbot) on Oct 12, 2012 at 17:50 UTC
    If you just want to match 0,1, or 2 and not "|", then your character class should be [012], not [0|1|2].