in reply to Re: Eternal question of parsing parentheses
in thread Eternal question of parsing parentheses

Hi

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