Help for this page

Select Code to Download


  1. 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
    );
    
  2. or download this
    my %isname;
    $isname{$_} = 1 foreach @names;
    if($isname{$name}) ...
    
  3. or download this
    if($name ~~ @names) ...
    
  4. or download this
    if(grep $name eq $_, @names) ...
    
  5. or download this
    use Regex::PreSuf;
    my $re = presuf(@names);
    if($name =~ /^($re)$/o) ...
    
  6. or download this
    my $re = join '|', @names;
    if($name =~ /^($re)$/o) ...
    
  7. or download this
    my $names = ' ' . join(' ', @names) . ' ';
    if(index($names, " $name ") >= 0) ...
    
  8. 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;