develooper Front page | perl.perl5.porters | Postings from October 2003

Re: /(\w|(?{++$n}))*/

Thread Previous | Thread Next
From:
Jeff 'japhy' Pinyan
Date:
October 29, 2003 12:41
Subject:
Re: /(\w|(?{++$n}))*/
Message ID:
Pine.LNX.4.44.0310291539410.2666-100000@perlmonk.org
On Oct 29, Jeff 'japhy' Pinyan said:

>Is that "|" supposed to be there?  The code
>
>  $n = 0;
>  "abc" =~ /(\w|(?{++$n}))*/;
>
>stores 'abc' in $& and 1 in $n.  The code
>
>  $n = 0;
>  "abc" =~ /\w*|(?{++$n})?/;
>
>doesn't change $n.

And somewhat related, why doesn't

  "abc" =~ /(b?|[ac])*/;

match 'abc'?  It matches '' (the zero b's at the beginning of the string).

-- 
Jeff "japhy" Pinyan      japhy@pobox.com      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About