Indeed. #!/usr/bin/perl
use strict; use warnings; my $line = "<elem1><elema>a < bad</elema>e1 < bad <elemb>b1 > bad<elemc>c</elemc>b2</elemb>e2</elem1>"; my @insides = $line =~ m{ \<elem1\> (.*?) \<\/elem1\> }gmsx; for my $inside ( @insides ){ while( $inside =~ m{ \G \<([^>^\s]*)\>[^<]* }gmsx ){ my $element = $1; # unless( $element =~ m{ \A \/ }msx ){ print "$1\n"; # } } } Any ideas... The [^<]* works to strip out "descendants text nodes" but not when < and > are present. --- On Mon, 1/5/09, Mr. Shawn H. Corey <shawnhco...@magma.ca> wrote: From: Mr. Shawn H. Corey <shawnhco...@magma.ca> Subject: Re: RegExp Searching within To: pjm...@yahoo.com Cc: beginners@perl.org Date: Monday, January 5, 2009, 8:55 AM On Mon, 2009-01-05 at 08:17 -0800, Paul M wrote: > If it were true XML, I would say all children's Node Names. > so: > <elema> <elemb> <elemc> > You mean all the descendants. The children of elem1 are elema and elemb. The descendants of elem1 are elema, elemb, and elemc. #!/usr/bin/perl use strict; use warnings; my $line = "<elem1><elema></elema><elemb><elemc></elemc></elemb></elem1>"; my @insides = $line =~ m{ \<elem1\> (.*?) \<\/elem1\> }gmsx; for my $inside ( @insides ){ while( $inside =~ m{ \G \<([^>]*)\> }gmsx ){ my $element = $1; unless( $element =~ m{ \A \/ }msx ){ print "$1\n"; } } } -- Just my 0.00000002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding.