>-----Original Message-----
>From: Wiggins d Anconia [mailto:[EMAIL PROTECTED]
>Sent: Monday, October 11, 2004 3:14 PM
>To: West, William M; [EMAIL PROTECTED]
>Subject: Re: in a regex- re-arrange $1..$n
>
>> the following is an as yet incomplete regex that i'm working on:
>>
>> $data = $_ =~
>>
s/<(name)>(.*?)<(desc)>(.*?)<(copy)>(.*?)<(license)>(.*?)<(entry)>//xg
>>
>>
>> every other capture ($1 $3 $5 $7 $9) is going to be used one way, the
>> other
>> captures will be used differently...  i'm wondering if there's a way
to
>> force the captures into particular numbered variable, so that
>> $1 =$1
>> $2 = $3
>> $3 = $5
>> $4 = $7
>> $5 = $9
>>
>
>How about just not capturing them to begin with?  If you add C<?:> to
>the beginning of your capture it will ignore the capture.  Having said
>that, why are you capturing to begin with if you are just going to
throw
>them away?  The parens in your example don't matter for the match to
work.


you misread- i intend to USE all of the captures- but i wanted to
categorize them more easily by "type", so ?: would be useless.

>
>> etc...  or is it even worth it for easier coding later on?
>>
>
>At the very least I would switch to named variables to make it more
>readable and prevent the chance that they get clobbered by a later
regex.

what i am likely going to do is finish the processing in the one s///,
so leaving them as is might not be a problem.   


i've worked on this since my last post::

$_ =~ s/<(.+?)>(.*?)<(.+?)>(.*?)<(.+?)>(.*?)<(.+?)>(.*?)<entry>/
        $css{$1}{open} $2 $css{$1}{close}
        $css{$3}{open} $4 $css{$3}{close}
        $css{$5}{open} $6 $css{$5}{close}
        $css{$7}{open} $8 $css{$7}{close}/xg


%css is an HoH- using half the captures as keys etc...   looks like this
will work well enough for me after all :)  

but i'm still wondering about the original question... with so much time
spent by me with regexen, i'd love to keep them as readable and
malleable
as i can.




willy
http://www.hackswell.com/corenth

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