use Regexp::Common; my $parens = qr/$RE{balanced}{-parens=>'()'}/; # ... # my fix $theParam =~ s/([A-Z]+)($parens)/&doFunc($1,$2)/geo; __END__ Using your script, it will print Example 1: func A returns <(func B returns <(2)>)> Example 2: func A returns <(func B returns <(2)>+func C returns <(func + D returns <()>)>)>
In reply to Re: How to find matching pairs
by rnahi
in thread How to find matching pairs
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |