in reply to Matching date range with pure regex

local $" = "|"; /^(?:@{[1950 .. 2050]})$/;

Abigail

Replies are listed 'Best First'.
Re: Re: Matching date range with pure regex
by halley (Prior) on Feb 17, 2004 at 13:03 UTC
    By way of explanation, this builds a long regexp through basic string interpolation like the following:
    /^(?:1950|1951|1952|1953|...|2049|2050)$/;
    After generating a regex like that, if you will be using it often, you might want to optimize it for common prefixes or suffixes.
    use Regex::PreSuf; my $re = presuf(1950..2050);

    --
    [ e d @ h a l l e y . c c ]

      If the OP wanted something optimized, he wouldn't have used a regex to begin with.

      Abigail