Bob Showalter wrote at Wed, 31 Jul 2002 21:34:02 +0200:
>> > $\ = "\n";
>> > $date = "20020731";
>> > print join "/", ($date =~ /(\d{4})(\d{2})(\d{2})/)[1,2,0];
>> # this works
>> > print join "/", ($date =~ /(\d{4})(\d{2}){2}/)[1,2,0]; #
>> this doesn't
>> >
>> The second pattern matches only
> -Original Message-
> From: Janek Schleicher [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 31, 2002 2:14 PM
> To: [EMAIL PROTECTED]
> Subject: Re: regex capturing
>
>
> Nikola Janceski wrote at Wed, 31 Jul 2002 17:27:22 +0200:
>
> > $\ = "
Nikola Janceski wrote at Wed, 31 Jul 2002 17:27:22 +0200:
> $\ = "\n";
> $date = "20020731";
> print join "/", ($date =~ /(\d{4})(\d{2})(\d{2})/)[1,2,0]; # this works
> print join "/", ($date =~ /(\d{4})(\d{2}){2}/)[1,2,0]; # this doesn't
>
> __END__
>
> why did the second pattern not capture t
essage-
> From: Bob Showalter [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 31, 2002 12:21 PM
> To: 'Nikola Janceski'; Beginners (E-mail)
> Subject: RE: regex capturing
>
>
> But it does capture the second occurrence (the 31). It doesn't capture
>
> -Original Message-
> From: Nikola Janceski [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, July 31, 2002 11:27 AM
> To: Beginners (E-mail)
> Subject: regex capturing
>
>
> $\ = "\n";
> $date = "20020731";
> print join "/"
Wednesday, July 31, 2002 11:55 AM
> To: Nikola Janceski; Beginners (E-mail)
> Subject: Re: regex capturing
>
>
> To capture the second occurance you have to surround the {2}
> with parens.
>
> print join "/", ($date =~ /(\d{4})(\d{2}{2})/)[1,2,0]
>
> T
t;
Sent: Wednesday, July 31, 2002 11:27 AM
Subject: regex capturing
> $\ = "\n";
> $date = "20020731";
> print join "/", ($date =~ /(\d{4})(\d{2})(\d{2})/)[1,2,0]; # this works
> print join "/", ($date =~ /(\d{4})(\d{2}){2}/)[1,2,0]; # this doesn
$\ = "\n";
$date = "20020731";
print join "/", ($date =~ /(\d{4})(\d{2})(\d{2})/)[1,2,0]; # this works
print join "/", ($date =~ /(\d{4})(\d{2}){2}/)[1,2,0]; # this doesn't
__END__
why did the second pattern not capture the second occurance of \d{2} ?
Is this the correct action? or should it cap