regex capturing

2002-07-31 Thread Nikola Janceski

$\ = \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 capture the second one in the
second example?
Is there a way to capture like so (like second example as I expected it to
work)?


Nikola Janceski

If you enjoy what you do, you'll never work another day in your life.
-- Confucius 




The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: regex capturing

2002-07-31 Thread Tanton Gibbs

To capture the second occurance you have to surround the {2} with parens.

print join /, ($date =~ /(\d{4})(\d{2}{2})/)[1,2,0]

Tanton
- Original Message -
From: Nikola Janceski [EMAIL PROTECTED]
To: Beginners (E-mail) [EMAIL PROTECTED]
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't

 __END__

 why did the second pattern not capture the second occurance of \d{2} ?
 Is this the correct action? or should it capture the second one in the
 second example?
 Is there a way to capture like so (like second example as I expected it to
 work)?


 Nikola Janceski

 If you enjoy what you do, you'll never work another day in your life.
 -- Confucius


 --
--
 
 The views and opinions expressed in this email message are the sender's
 own, and do not necessarily represent the views and opinions of Summit
 Systems Inc.


 --
 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]




RE: regex capturing

2002-07-31 Thread Nikola Janceski

Nested quantifiers before HERE mark in regex m/(\d{4})(\d{2}{  HERE 2})/
at line.
when i do that, so that's not the answer.
print join /, ($date =~ /(\d{4})(\d{2}{2})/)[1,2,0];

 -Original Message-
 From: Tanton Gibbs [mailto:[EMAIL PROTECTED]]
 Sent: 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]
 
 Tanton
 - Original Message -
 From: Nikola Janceski [EMAIL PROTECTED]
 To: Beginners (E-mail) [EMAIL PROTECTED]
 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't
 
  __END__
 
  why did the second pattern not capture the second occurance 
 of \d{2} ?
  Is this the correct action? or should it capture the second 
 one in the
  second example?
  Is there a way to capture like so (like second example as I 
 expected it to
  work)?
 
 
  Nikola Janceski
 
  If you enjoy what you do, you'll never work another day in 
 your life.
  -- Confucius
 
 
  
 --
 
 --
  
  The views and opinions expressed in this email message are 
 the sender's
  own, and do not necessarily represent the views and 
 opinions of Summit
  Systems Inc.
 
 
  --
  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]
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: regex capturing

2002-07-31 Thread Bob Showalter

 -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 /, ($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} ?

But it does capture the second occurrence (the 31). It doesn't capture
the first (the 07).

In the absence of /g, it would seem that since there are only two
sets of parens in the second regex, only two values can be captured.
The {2} quanitifier would simply cause $2 to be reused.

 Is this the correct action? or should it capture the second one in the
 second example?
 Is there a way to capture like so (like second example as I 
 expected it to
 work)?

I would think /g would have to be used somehow, but I do not know
how.

Of course, the simple:

   /(\d{2})/g

works, returning '20', '02', '07', '31'.

But that's not what you're after.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: regex capturing

2002-07-31 Thread Nikola Janceski

Correct actually. It just didn't dawn on me that $2 was being reused but
that is unlike perl to do that.
I would have thought that it would know that I wanted 2 captures. So is this
just a new issue that hasn't come up before? or is it something seen just
nothing done about it?

I am using the first example anyway because I need it working now, but I was
curious to learn if this is a problem/bug or if this was the intended
result. Perldocs didn't have much about this kind of situation, so I don't
know what the intended result would be.

 -Original Message-
 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
 the first (the 07).
 
 In the absence of /g, it would seem that since there are only two
 sets of parens in the second regex, only two values can be captured.
 The {2} quanitifier would simply cause $2 to be reused.
 



The views and opinions expressed in this email message are the sender's
own, and do not necessarily represent the views and opinions of Summit
Systems Inc.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: regex capturing

2002-07-31 Thread Janek Schleicher

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 the second occurance of \d{2} ?
 Is this the correct action? or should it capture the second one in the
 second example?

The second pattern matches only these 12 days in a year:

Jan 01
Feb 02
Mar 03
Apr 04
May 05
Jun 06
Jul 07
Aug 08
Sep 09
Oct 10
Nov 11
Dec 12


Cheerio,
Janek


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: regex capturing

2002-07-31 Thread Bob Showalter

 -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:
 
  $\ = \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 capture the second 
 one in the
  second example?
 
 The second pattern matches only these 12 days in a year:
 
 Jan 01
 Feb 02
 Mar 03
 Apr 04
 May 05
 Jun 06
 Jul 07
 Aug 08
 Sep 09
 Oct 10
 Nov 11
 Dec 12

Huh?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: regex capturing

2002-07-31 Thread Janek Schleicher

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 these 12 days in a year:
 .
 
 Huh?

Oops, forget what I wrote.
I just read too quick and so I read it as something
like (\d{4})(\d{2})\1


Bye,
Janek

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]