Question
Joined: Apr 15, 2009
Pts: 3
Rank: 21
How do I strip html from a string in perl?
I just want to remove all html from the < to > and keep only the remaining text.
Asked on: Apr 15, 2009
Answer
Was this answer helpful?
Joined: Apr 16, 2009
Pts: 1
Rank: 41
There are multiple ways of doing this.
You can use the HTML::Strip module.
There are other perl modules that do the function as well like HTML::Parser or HTML::FormatText
or if you want to just use a 1 line regex expression, you can use this code.
That will remove all html tags from the string. But it is not extremely helpful if you want to work with the html.
You can use the HTML::Strip module.
There are other perl modules that do the function as well like HTML::Parser or HTML::FormatText
or if you want to just use a 1 line regex expression, you can use this code.
Perl Code Snippet:
$string_with_html =~ s/<.+?>//g;
That will remove all html tags from the string. But it is not extremely helpful if you want to work with the html.
Answered on: Apr 16, 2009
Got the Answer?
or
to add answer.
