- or download this
my @names = qw(
amp lt gt apos quot nbsp iexcl cent pound curren yen brvbar sect uml
...
lceil rceil lfloor rfloor lang rang loz
spades clubs hearts diams
);
- or download this
my %isname;
$isname{$_} = 1 foreach @names;
if($isname{$name}) ...
- or download this
if($name ~~ @names) ...
- or download this
if(grep $name eq $_, @names) ...
- or download this
use Regex::PreSuf;
my $re = presuf(@names);
if($name =~ /^($re)$/o) ...
- or download this
my $re = join '|', @names;
if($name =~ /^($re)$/o) ...
- or download this
my $names = ' ' . join(' ', @names) . ' ';
if(index($names, " $name ") >= 0) ...
- or download this
s/&((?:(#\d+|0x[\da-f]+)|([a-z0-9]+));?)?/
$2 ? "&$2;" # numerical
: $3 && $isname{$3} ? ($3 eq 'apos' ? "'" : "&$3;") # named
: ($1 ? "&$1" : "&") # not an entity
/gie;