From: "Mr. Shawn H. Corey" <[EMAIL PROTECTED]> > On Sat, 2008-11-29 at 20:56 -0800, ZuLuuuuuu wrote: > > How can I match structures like > > this: > > > > [block] > > this is a block > > [block] > > this is another block > > [/block] > > first block ends > > [/block] > > > > You can't. > > In order to correctly interpret a structure like this you need a > finite-state automation (FSA) with a push-down stack. This structure > has unbounded nested contexts which means anything simpler won't work.
OTOH, he can match the innermost [block]...[/block], remove it or replace by something that doesn't contain either "tag", match the next one ... It would not be pretty, but it would be doable. And actually if there really is just one tag and if we can assume that the text doesn't contain \x01 nor \x00 we might use a trick: $text = <<'*END*'; [block] this is a block [block] this is another block [/block] first block ends [/block] *END* print "TEXT: $text\n\n"; $text =~ s/\[block\]/\x01/g; print "TEXT: $text\n\n"; $text =~ s/\[\/block\]/\x00/g; print "TEXT: $text\n\n"; 1 while ($text =~ s{\x01([^\x00\x01]*)\x00}{ print "found '$1'\n\n"; 'HERE WAS BLOCK' }ge); print "TEXT: $text\n\n"; Now whether this is of anyuse to ZuLuuuu noone can tell. Jenda ===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/