On Jul 15, Jeff 'japhy' Pinyan said:
>On Jul 15, Luca Veraldi said:
>
>> qr{(?>([\(\[\{])(?:(?>[^\(\)\[\]\{\}]*)|(??{$re}))*(?(?{$1 eq "("})\)|(?(?{$1 eq
>"["})\]|\})))}ox;
>
>That looks pretty solid to me, except that it's very stingy in what it
>allows to be inside balanced parts.
Err, nevermind that "stingy" comment. I misread part of the regex.
Anyway, mine is just a slightly more drawn out version of yours. I'm not
fond of putting TOO much logic into a regex via (?(...)...|...). In fact,
I'd be happier doing:
my %opp = ( '[' => ']', '(' => '\)', '{' => '}' );
my $balanced;
$balanced = qr%
(?:
(?> [^][(){}]+ ) # non [] () {} chars
|
( [[({] ) (??{ $balanced }) (??{ $opp{$1} })
)*
%x;
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** Manning Publications, Co, is publishing my Perl Regex book **
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]