sangam1 has asked for the wisdom of the Perl Monks concerning the following question:
When I run the program:$_ = q!0a { 1a { 1.1a } 1b { 1.2a } 1c { 1.3a 1.3b } } 0b { 2a { 2 +.1a} } 0c!; while(m!{[^{]+(({.*?})*)[^{]+}!g){ $inside = $1; print $&,"\n"; while($inside =~ m!{[^{]+(({.*?})*)[^{]+}!g){ print "\t",$&,"\n"; } }
{ 1a { 1.1a } 1b { 1.2a } 1c { 1.3a 1.3b } }
{ 1.1a }
{ 1.2a }
{ 1.3a 1.3b }
{ 2a { 2.1a} }
{ 2.1a}
Now you know exactly what I am trying to do...
When I change my string to..
I get the output$_ = q!0a { 1a { 1.1a } 1b { 1.2a } 1c { 1.3a { 1.3.1a } 1.3b } } +0b { 2a { 2.1a} } 0c!;
{ 1a { 1.1a } 1b { 1.2a } 1c { 1.3a { 1.3.1a } 1.3b } }
{ 1.1a }
{ 1.2a }
{ 1.3.1a }
{ 2a { 2.1a} }
{ 2.1a}
What I want is
{ 1a { 1.1a } 1b { 1.2a } 1c { 1.3a 1.3b } }
{ 1.1a }
{ 1.2a }
{ 1.3a { 1.3.1a } 1.3b }
{1.3.1.a}
{ 2a { 2.1a} }
{ 2.1a}
Thus nested braces upto any level should be taken care..
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Braces
by chipmunk (Parson) on Feb 16, 2001 at 21:18 UTC | |
|
Re: Braces
by TheoPetersen (Priest) on Feb 16, 2001 at 21:21 UTC | |
|
Re (tilly) 1: Braces
by tilly (Archbishop) on Feb 16, 2001 at 21:22 UTC | |
|
Re: Braces
by I0 (Priest) on Feb 17, 2001 at 08:17 UTC |