[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Help with RegEx



"Raz C. Niculita" wrote:
>I have to extract dates from a text, store them into an array and then use
>AppleScript to save them into a FileMaker Pro database.
>The dates in the text are in the following format: mm/dd/yy.
>
>I have tried some expressions, but since I am not experienced, Perl returns
>the entire line that contains the date.

Suggestion:
#!perl -w

$teststring = <<EOF;
Greenblatt & Seay	4:24 PM 11/12/00 +0100	Re: [MacPerl] Help with RegEx
Detlef Lindenthal	10:01 PM 11/12/00 +0100	Re: [MacPerl] Help with RegEx
Bruce Van Allen	1:27 PM 11/12/00 -0800	Re: [MacPerl] MacPerl and 
FileMaker via DBI?
Axel Rose	11:24 PM 11/12/00 +0100	Re: [MacPerl] MacPerl and 
FileMaker via DBI?
John W Baxter	7:06 PM 11/12/00 -0800	Re: [MacPerl] Help with RegEx
Detlef Lindenthal	8:30 AM 11/13/00 +0100	Re: [MacPerl] Help with RegEx
EOF

@datearray = $teststring =~ /(\d\d\/\d\d\/\d\d)/g;

# in the file context this might be implemented as

undef $/;
open(IN, 'testfile.txt') || die "can't open the 'testfile.txt': $!";
while (<IN>) { @datearray = /(\d\d\/\d\d\/\d\d)/g };

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org