use strict; while () { chomp; my $match = "'$1'" if m#^((?:[^<]*|<(?!b>)[^>]+>)*?)$#ism; $match = "" unless defined $match; print "$_ matches $match\n" }; __DATA__ this should match This should not match What about this? And this malformed piece?
((?:[^<]*|<(?!b>)[^>]+>)*?)
this should match
This should not match
What about this?
And
this
## //p[not descendant::b()]/text()