:
() , .. , .
. , .
, , Perl:
my $str = "((char)((x+y)&1))";
my $w = length length $str ;
my $rx = qr{ (?<PAREN>
\(
(?:
[^()] +
|
(?&PAREN)
) *
\)
)
}x;
while ($str =~ /(?=$rx)/g) {
printf "Matched from %*d to %*d: %s%s\n" =>
$w => pos($str),
$w => pos($str) + length($+{PAREN})-1,
" " x pos($str) => $+{PAREN};
}
:
Matched from 0 to 16: ((char)((x+y)&1))
Matched from 1 to 6: (char)
Matched from 7 to 15: ((x+y)&1)
Matched from 8 to 12: (x+y)
, , , . , , , , .
Perl, Java . ☹