maj12 has asked for the wisdom of the Perl Monks concerning the following question:
logging {
category lame-servers { null; };
category cname { null; };
};
zone "." in {
type hint;
file "root.cache";
};
zone "127.IN-ADDR.ARPA" {
type slave;
file "127";
masters { 10.10.1.113; };
};
Returns:
logging { category lame-servers { null; };
category cname { null; };
zone "." in { type hint; file "root.cache";};
zone "127.IN-ADDR.ARPA" { type slave; file "127"; masters { 10.10.1.113; };
It's splitting when it finds "{}"'s embedded in "{}".
Now, I want to break it up into 3 logical "sections". I can get it to split using this regex:
foreach my $lines(@temparray) #where temparray is the above { chomp $lines; $string=$string.$lines; } while($string=~/(\w+ )([\w\W\d]+?\};)+?/g) { print "$1$2<br>"; }
while($string=~/(\w+ )([\w\W\d]+?\};\n)+?/gm)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: multiline, global regex
by jeroenes (Priest) on Oct 18, 2001 at 12:03 UTC | |
|
Re: multiline, global regex
by drinkd (Pilgrim) on Oct 18, 2001 at 04:04 UTC | |
|
Re: multiline, global regex
by maj12 (Novice) on Oct 18, 2001 at 16:35 UTC |