Posted By


Activetuts on 01/13/11

Tagged


Statistics


Viewed 671 times
Favorited by 5 user(s)

Strip HTML Markup


/ Published in: ActionScript 3
Save to your folder(s)

<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>


Copy this code and paste it in your HTML
  1. function stripTags(string:String):String
  2. {
  3. var s:String = string;
  4. var regexp:RegExp = new RegExp("<[^<]*<", "gi");
  5. return s.replace(regexp, "");
  6. }

URL: http://enva.to/e4ig6z

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.