$text = "<paragraph>some <paragraph>some data</paragraph>data</paragra +ph><paragraph>more data</paragraph><paragraph>even more data</paragra +ph>"; my $depth = 0; $text =~ s{(<(/)?paragraph>)}{check($depth)}gie; print "$text\n"; sub check { if($2) { $_[0]--; if($_[0] == 0) { return $1; } $_[0] = 0 if $_[0] < 0; } else { $_[0]++; return $1 if $_[0] == 1; } return ''; }
In reply to Re: Excluding groups of characters in regular expressions
by suaveant
in thread Excluding groups of characters in regular expressions
by semirhage
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |