Hi Peter

Am Montag, 11. April 2005 07.41 schrieb Peter Rabbitson:
> I am getting this:
> [EMAIL PROTECTED]:~$ perl -e "'123456-123456' =~ /^ (\d{2}){3} (?: - 
> (\d{2}){3} )?
> $/x ? print 'yep' : print 'nope';" Panic opt close in regex m/^ (\d{2}){3}
> (?: - (\d{2}){3} )? $/ at -e line 1.
>
> Google does not turn much if anything about this error... Why is this
> happening? If I remove ?: everything goes well but it defies the idea of
> the exercise to get an optional 3 pair set of digits parsed as $4 $5 $6 in
> the same pass as $1 $2 $3.

No explanation for this error... but:

You won't have $1 $2 $3 and $4 $5 $6 anyway since
the "{3}" in "(\d{2}){3}" only indicates to match 3 times what is _within_ the 
brackets; it does not _capture_ 3 times. Only literally present/countable 
brackets capture.

The example without the "?:" to compensate my bad english:

===
[EMAIL PROTECTED] $ perl
use strict; use warnings;
'123456-123456' =~ /^ (\d{2}){3} (- (\d{2}){3} )? $/x;
print "1:$1 2:$2 3:$3 4:$4 5:$5 6:$6 7:$7";
===
Use of uninitialized value in concatenation (.) or string at - line 3.
Use of uninitialized value in concatenation (.) or string at - line 3.
Use of uninitialized value in concatenation (.) or string at - line 3.
Use of uninitialized value in concatenation (.) or string at - line 3.
1:56 2:-123456 3:56 4: 5: 6: 7:
===

greetings joe

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to