my %good = map +($_ => 1), qw{ pre strong }; my $string = "xxx
xxxxxxxxx"; while ($string =~ m{<(\w+)>}g) { warn "bad word '$1'" unless $good{$1}; } #### print "ok\n" if $string =~ m{ ^ ( [^<] | < (?: pre | strong ) > )* $ }x;
## print "ok\n" if $string =~ m{ ^ ( [^<] | < (?: pre | strong ) > )* $ }x;