I simplified the code, and replaced tr/()/<>/ to make it more readable:
$_='a<b<c<d><e>>f>g<h><<i>j>'; $re = qr{ < # anchor at first paren as wanted ( # paren group 1 (?: (?> [^<>]+) # Non-parens without backtracking | < (?1) # Recurse to start of paren group 1 > )* ) }x; /$re/; print $1;
perl /tmp/tst2.pl b<c<d><e>>f
Cheers Rolf
In reply to Re^2: Eternal question of parsing parentheses
by LanX
in thread Eternal question of parsing parentheses
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |