Posted By

tuffstudio on 01/19/11


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

liakwee
kure69
BrockSamsom


Strip HTML Markup


 / Published in: ActionScript 3
 

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 “Click here to find out more” would simply be converted to “Click here to find out more.”. This returns a new string, leaving the input string unchanged.

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

Report this snippet  

You need to login to post a comment.