in reply to A better regex

Here is one possiblity
$zipfile =~ /(A|B)FILE_([0-9]+)/; $day = $2;
However if you are just looking for digits try:
$zipfile =~ /([0-9]+)[^0-9]?/; $day = $1;

Replies are listed 'Best First'.
Re: Re: A better regex
by Anonymous Monk on Sep 24, 2003 at 00:52 UTC

    Why capture when you don't have to?

    $zipfile =~ /(?:A|B)FILE_(\d+)/; $day = $1;

    Or you can use a character class (since the strings are 1 char long).

    $zipfile =~ /[AB]FILE_(\d+)/; $day = $1;

    Of course, you could always use the uber-sexy:

    ($day) = $zipfile =~ /[AB]FILE_(\d+)/;

    ;-P

    Anonymously yours,
    Anonymous Nun