Return to Snippet

Revision: 39138
at January 13, 2011 23:34 by Activetuts


Initial Code
function stripTags(string:String):String
{
    var s:String = string;
    var regexp:RegExp = new RegExp("<[^<]*<", "gi");
    return s.replace(regexp, "");
}

Initial URL
http://enva.to/e4ig6z

Initial Description
<p>If there is ever a time when you load text from an external source containing unwanted HTML markup use the following function. This uses a regular expression to strip all HTML tags from the input string. The string "&lt;strong&gt;Click &lt;a href='http://example.com'&gt;here&lt;/a&gt; to find out more&lt;/strong&gt;" would simply be converted to "Click here to find out more.". This returns a new string, leaving the input string unchanged.</p>

Initial Title
Strip HTML Markup

Initial Tags

                                

Initial Language
ActionScript 3