http://www.perlmonks.org?node_id=547596

gopalr has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I tried the following code to match the whole brackets which are inside the Main Brackets.

use strict; my $text='(one dfd(two(three)four()(five)df())df)'; print $& if $text=~m#(\([^()]*(\([^()]*\))+[^)]*\))+#;

It Prints only

(two(three)four()

But I need Out put Whole Opened and Closed Brackets

Need Output:

(one dfd(two(three)four()(five)df())df)

Please advice me in regulare expression

Thanks in Advance,
Gopal R.