nix, shell, perl, php, mysql and mac os x tips and tricks

Friday, September 19, 2014

Perl subroutine to fix when html entities get recursively applied

sub enEntity {
 
 my $string = shift;
 
 if ($string =~ /&/) {
  #print "string: $string\n";
 }
 if ($string =~ /&(amp;)+quot;/) { $string =~ s/&(amp;)+quot;/"/ig; }
 if ($string =~ /"/) { $string =~ s/"/"/ig; } 
 if ($string =~ /"/) { $string =~ s/"/"/ig; } 
 if ($string =~ /&(amp;)+apos;/) { $string =~ s/&(amp;)+apos;/'/ig; }
 if ($string =~ /'/) { $string =~ s/'/'/ig; } 
 if ($string =~ /'/) { $string =~ s/'/'/ig; } 
 if ($string =~ /&(amp;)+/) { $string =~ s/&(amp;)+/&/ig; }
 if ($string =~ /&/) { $string =~ s/&/&/ig; }
 if ($string =~ /&/) { $string =~ s/&/&/ig; }
 #optional
        #$string = unidecode($string);

 return ($string);

} # end sub unescape html entities

5 comments:

  1. But seriously, native HTML is repetitive and annoying to write. Emmet provides an intuitive and sleek alternative. psd to html

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete
  3. A PSD file, as we all are aware of, is a photo shop design file which gives us the liberty to creatively design the look and appeal of our websites.
    StartPoint Web Design

    ReplyDelete
  4. Caesars Palace in Las Vegas - JMT Hub
    Harrah's Cherokee 울산광역 출장안마 Casino 강릉 출장마사지 & Hotel. Harrah's 의정부 출장마사지 Cherokee Casino 원주 출장마사지 Resort is operated by Caesars Entertainment. This casino hotel is 광명 출장마사지 located in

    ReplyDelete
  5. Even although it may appear slightly restricted – the selection is versatile considering that you’ll find video games from quantity of} game studios. As for the sport choice, this operator features over 350 video games from top-tier builders like Dragon Gaming and Betsoft. You will find loads of video slots, table video games, specialty video games, and stay casino video 메리트카지노 games to play. Another high on-line casino we couldn’t assist however discover is Red Dog. This dog-themed operator is legendary for its video poker choice and matching bonus. You can play 14 titles (that’s a lot!), together with All American Poker, Bonus Deuces, Aces and Eights, heaps of|and lots of} more free of charge or for actual cash.

    ReplyDelete