Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
for ( '<1>', # want match '<<2>>', # want match '<<3>', # want fail '<<<4>>', # want fail '<<5>>>>', # want fail ){ use vars qw' $LEN '; print "$_\n"; print " $_\n" for m( (?<! < ) # no preceeding < (?><+)(?{ $LEN = length $^N; }) ( [^><]* ) (?(?{ $LEN > 0 })(??{ '>' x $LEN })) (?! > ) # no following > )x; print " LEN = $LEN\n"; } __END__ <1> LEN = 0 <<2>> LEN = 0 <<3> LEN = 0 <<<4>> LEN = 0 <<5>>>> LEN = 0
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: experimental regex (?(?{code}) conditional (??{ 'code' }) )
by ikegami (Patriarch) on Nov 12, 2010 at 15:11 UTC | |
|
Re: experimental regex (?(?{code}) conditional (??{ 'code' }) )
by JavaFan (Canon) on Nov 12, 2010 at 17:10 UTC | |
|
Re: experimental regex (?(?{code}) conditional (??{ 'code' }) )
by Marshall (Canon) on Nov 12, 2010 at 16:36 UTC | |
by Anonymous Monk on Nov 12, 2010 at 16:53 UTC | |
by Marshall (Canon) on Nov 12, 2010 at 17:07 UTC | |
by Anonymous Monk on Nov 12, 2010 at 17:33 UTC |