Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
$dir = 'C:/texts/'; opendir(directory, $dir) or die "cant"; while ( $file = readdir directory) { next if $file=~/^\./; $rfname = $dir.$file; # print "Found file: '$rfname'\n"; open (CONT, $rfname); while (<CONT>) { if ( $_ =~ m/[0-3]?[0-9(th)?(st)?(nd)?(rd)?]\s+(Jan(uary)?|Feb +(ruary)?|Mar(ch)?|Apr(il)?|May|Jun(e)?|Jul(y)?|Aug(ust)?|Sep(tember)? +|Oct(ober)?|Nov(ember)?|Dec(ember)?)\s+[0-9]?[0-9]?[0-9][0-9]/ig ) { print "$file\t $_\n"; } elsif ( $_ =~ m/(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May| +Jun(e)?|Jul(y)?|Aug(ust)?|Sep(tember)?|Oct(ober)?|Nov(ember)?|Dec(emb +er)?)\s+[1-3]?[0-9](th)?(nd)?(st)?(rd)?\s+[0-9]?[0-9]?[0-9][0-9]/ig ) { print "$file\t $_\n"; } } }
Petruchio Thu Jul 12 01:55:32 EDT 2001: Added code tags.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
RE: Problem extracting date with regex
by jjhorner (Hermit) on Jun 21, 2000 at 16:46 UTC | |
|
Re: Problem extracting date with regex
by raflach (Pilgrim) on Jun 21, 2000 at 17:15 UTC | |
|
Re: Problem extracting date with regex
by davorg (Chancellor) on Jun 21, 2000 at 16:48 UTC | |
by Adam (Vicar) on Jun 22, 2000 at 05:21 UTC | |
|
Re: Problem extracting date with regex ('x' regex modifier)
by Russ (Deacon) on Jun 22, 2000 at 01:18 UTC |