Re: How to filter out { } block in text file

2010-11-16 Thread C.DeRykus
On Nov 16, 1:54 pm, vincent.mc...@gmail.com (Vincent Li) wrote: > On Tue, Nov 16, 2010 at 1:11 PM, Shawn H Corey wrote: > > > On 10-11-16 04:07 PM, Vincent Li wrote: > > >> My aim is to remove specific profile.*{} block from that file > > > Yes, but if the {} blocks are nestable, then you can't do

Re: How to filter out { } block in text file

2010-11-16 Thread Brian Fraser
Assuming your brackets are balanced, here's a drop-in regex for you: /$profile .*? ( #Group 1 { (?: [^{}]+ | (?1) #If not brackets, eat up. Otherwise, recurse on group 1. )*? } ) /gx; Minimally adapted from Anon.'s

Re: How to filter out { } block in text file

2010-11-16 Thread Jim Gibson
On 11/16/10 Tue Nov 16, 2010 2:25 PM, "Vincent Li" scribbled: > On Tue, Nov 16, 2010 at 2:14 PM, Jim Gibson wrote: >> On 11/16/10 Tue  Nov 16, 2010  1:07 PM, "Vincent Li" >> scribbled: >> >>> On Tue, Nov 16, 2010 at 9:38 AM, Jim Gibson wrote: >> You need a parser to do this righ

Re: How to filter out { } block in text file

2010-11-16 Thread Vincent Li
On Tue, Nov 16, 2010 at 2:14 PM, Jim Gibson wrote: > On 11/16/10 Tue  Nov 16, 2010  1:07 PM, "Vincent Li" > scribbled: > >> On Tue, Nov 16, 2010 at 9:38 AM, Jim Gibson wrote: > >>> >>> You need a parser to do this right. You might have some luck by reading the >>> entire file into a scalar varia

Re: How to filter out { } block in text file

2010-11-16 Thread Jim Gibson
On 11/16/10 Tue Nov 16, 2010 1:07 PM, "Vincent Li" scribbled: > On Tue, Nov 16, 2010 at 9:38 AM, Jim Gibson wrote: >> >> You need a parser to do this right. You might have some luck by reading the >> entire file into a scalar variable and using the Text::Balanced module >> together with some

Re: How to filter out { } block in text file

2010-11-16 Thread Vincent Li
On Tue, Nov 16, 2010 at 1:11 PM, Shawn H Corey wrote: > On 10-11-16 04:07 PM, Vincent Li wrote: >> >> My aim is to remove specific profile.*{} block from that file > > Yes, but if the {} blocks are nestable, then you can't do it with regular > expressions alone. > right, I only have one level nes

Re: How to filter out { } block in text file

2010-11-16 Thread Shawn H Corey
On 10-11-16 04:07 PM, Vincent Li wrote: My aim is to remove specific profile.*{} block from that file Yes, but if the {} blocks are nestable, then you can't do it with regular expressions alone. -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization

Re: How to filter out { } block in text file

2010-11-16 Thread Vincent Li
On Tue, Nov 16, 2010 at 9:38 AM, Jim Gibson wrote: > On 11/16/10 Tue  Nov 16, 2010  9:01 AM, "Vincent Li" > scribbled: > >> Hi List, >> >> I have a text test.txt file looks like below: >> >> stp instance 0 { >>    interfaces 1.1 { >>          external path cost 2 >>          internal path cos

Re: How to filter out { } block in text file

2010-11-16 Thread Jim Gibson
On 11/16/10 Tue Nov 16, 2010 9:01 AM, "Vincent Li" scribbled: > Hi List, > > I have a text test.txt file looks like below: > > stp instance 0 { >interfaces 1.1 { > external path cost 2 > internal path cost 2 > } >vlans { > internal > vlan10

Re: How to filter out { } block in text file

2010-11-16 Thread Shawn H Corey
On 10-11-16 12:01 PM, Vincent Li wrote: how can I find a specific profile { } block and remove/replace that part from the file You will need a Finite-State Automation (FSA) with a push-down stack. -- Just my 0.0002 million dollars worth, Shawn Programming is as much about organization

How to filter out { } block in text file

2010-11-16 Thread Vincent Li
Hi List, I have a text test.txt file looks like below: stp instance 0 { interfaces 1.1 { external path cost 2 internal path cost 2 } vlans { internal vlan10 } } profile http http_global { defaults from http max header size 38912 encryp