How can I strip HTML in a string using Perl?

后端 未结 3 1812
青春惊慌失措
青春惊慌失措 2021-02-04 12:59

Is there anyway easier than this to strip HTML from a string using Perl?

$Error_Msg =~ s|||ig;
$Error_Msg =~ s|||ig;
$Error_Msg =~ s|

        
3条回答
  •  忘掉有多难
    2021-02-04 13:15

    Assuming the code is valid HTML (no stray < or > operators)

    $htmlCode =~ s|<.+?>||g;
    

    If you need to remove only bolds, h1's and br's

    $htmlCode =~ s###g
    

    And you might want to consider the HTML::Strip module

提交回复
热议问题