Posted By

Activetuts on 01/13/11


Tagged


Versions (?)

Who likes this?

13 people have marked this snippet as a favorite

chus
elbjoern
toxin20
leadingmannigel
ichnoweb
kure69
albertomori
AndrewPotter
JaaQ
im3der
elderhsouza
coutlasssupreme
flashdeveloper


Strip HTML Markup


 / Published in: ActionScript 3
 

URL: http://enva.to/e4ig6z

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 "<strong>Click <a href='http://example.com'>here</a> to find out more</strong>" 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  

Comments

RSS Icon Subscribe to comments
Posted By: mgeduld on February 1, 2011

I think the final less-than symbol should be a greater-than symbol.

Posted By: coder_808 on May 31, 2011

Yes it should. Thanks this was useful.

You need to login to post a comment.