How about this?
while($_ =~ /(\d{1,2}\/\d{1,2}\/\d{4})/g){
push @q,$1;
}
Perl assigns the variable $1 to the first match in parentheses. ($2 for the
next match within the same regex, and so on)
The regex above matches:
One or two digits \d{1,2}
followed by
a backslash \/
followed by
one or two digits \d{1,2}
followed by
a backslash \/
followed by
four digits \d{4}
-----Original Message-----
From: Rum Pel [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, September 17, 2002 9:18 PM
To: [EMAIL PROTECTED]
Subject: grouping regex match return values
I want to pick dates from a file, I did it the following way:
-----
$day = "([12]?[0-9]|30|31)";
$weekday = "(Mon|Tue|Wed|Thu|Fri|Sat|Sun)";
$month = "([1-9]|10|11|12|Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)";
$year = "(1999|2000|2001|2002)";
$query = "$month\/$day\/$year";
@q = "Today is Tue 9/17/2002 Tomorrow is 10/17/2002?" =~ /$query/g;
print "q = " . Dumper(@q);
-----
Now, the array q has 6 values - 9, 17, 2002, 10, 17, 2002.
Instead I want two values only - "9/17/2002", "10/17/2002"
do i need to rewrite my query?
_________________________________________________________________
MSN Photos is the easiest way to share and print your photos:
http://photos.msn.com/support/worldwide.aspx
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]