Welcome Forums Aliases nohtml – Remove HTML characters from a string

  • This topic has 1 voice and 0 replies.
Viewing 0 reply threads
  • Author
    Posts
    • #441
      Avatarbleepy
      Keymaster

      Description:
      Removes HTML entities from strings, mainly for usage in socket scripts.

      Usage:
      $nohtml(string)

      Example:
      $nohtml(<h1>Heading</h1><p>I like turtles</p>)

      Code:

      alias nohtml {
        var %x, %i = $regsub($1-,/< [^>]+(?:>|$)|^[^<>]+>/g,$chr(32),%x), %a = 1
        while ($regex(*,%x,/(&#(\d+?);)/)) { if ($regml(*,1).pos < %a) { goto more } | %x = $replace(%x,$regml(*,1),$chr($regml(*,2))) | inc %a }
        :more
        %x = $replacecs(%x,°,°,Í,í,º,º,§,§,Î,î,Ù,ù,<,<,´,´,>,>,¬,¬,Á,á,Õ,õ,Ç,ç,ª,ª,Ô,ô,Ó,ó,Ý,ý,µ,µ,Å,å,÷,÷,Ë,ë,¡,¡,Ã,ã,Ì,ì,&,&,³,³,­,­,®,®,¾,¾,ÿ,ÿ,À,à,¿,¿,Ê,ê,£,£,Ø,ø,©,©)
        %x = $replacecs(%x,»,»,·,·,Ü,ü,±,±,²,²,¼,¼,×,×,Ï,ï,¥,¥,¶,¶,È,è,Ð,ð,¨,¨, ,$chr(160),¯,¯,ß,ß,¸,¸,¤,¤,Ö,ö,Ú,ú,¦,¦,",",Þ,þ,«,«,Ä,ä,Ò,ò,¢,¢,É,é,¹,¹,Æ,æ,Â,â,½,½,Û,û,Ñ,ñ)
        return %x
      }
      • This topic was modified 9 years ago by Avatarbleepy.
      • This topic was modified 9 years ago by Avatarbleepy.
Viewing 0 reply threads
  • The forum ‘Aliases’ is closed to new topics and replies.