in reply to $1
Regexes are bad enough. If we can use variable interpolation in them, it makes them much easier to grok.$month = '(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)? |Apr(?:il)?|May|Jun(?:e)? |Jul(?:y)?|Aug(?:ust)?|Sep(?:tember)? |Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\s+'; $day = '[0-3]?[0-9](?:th|st|nd|rd)?,?\s+'; # I tossed an optional comm +a (,?) # in there in case we have +June 1st, 2000 $year = '[0-9]{2,4}'; opendir(DIRECTORY, $dir) or die "Can't open $dir: $!\n"; while($file = readdir DIRECTORY){ next if $file=~/^\./; $rfname=$dir . $file; open (CONT, $rfname); while (<CONT>){ if(/( (?:${day}${month}${year}) | (?:${month}${day}${year}) ) /ixo) { print "$1\n"; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Re: $1
by Odud (Pilgrim) on Jun 21, 2000 at 22:56 UTC |